Project

General

Profile

Actions

Bug #10136

closed

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

Added by akr (Akira Tanaka) over 10 years ago. Updated over 10 years ago.

Status:
Closed
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 1 (0 open1 closed)

Related to Ruby master - Bug #10135: Time.at is inaccurateRejectedakr (Akira Tanaka)08/15/2014Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0