Project

General

Profile

Bug #10136

printf("%.60f\n", 0.1r) shows 0.100000000000000005551115123125782702118158340454101562500000

Added by akr (Akira Tanaka) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.0dev (2014-08-15 trunk 47187) [x86_64-linux]
[ruby-core:64382]

Description

printf shows 0.1r (rational) not 0.1 as follows.

% ./ruby -ve 'printf "%.60f\n", 0.1r'
ruby 2.2.0dev (2014-08-15 trunk 47187) [x86_64-linux]
0.100000000000000005551115123125782702118158340454101562500000

It seems printf converts the rational argument to a float.

I expect 0.100000000000000000000000000000000000000000000000000000000000 instead of
0.100000000000000005551115123125782702118158340454101562500000.


Related issues

Related to Ruby trunk - Bug #10135: Time.at is inaccurateRejected08/15/2014Actions

Associated revisions

Revision 1d196e0d
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Revision 47214
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

History

Updated by naruse (Yui NARUSE) almost 5 years ago

  • Related to Bug #10135: Time.at is inaccurate added

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r47214.


sprintf.c: rational 'f' format

  • sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136]

Also available in: Atom PDF