Project

General

Profile

Actions

Bug #4656

closed

Float#to_s can produce too many digits

Added by mrkn (Kenta Murata) about 11 years ago. Updated about 11 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3dev (2011-05-09 trunk 31491) [x86_64-darwin10.7.0]
Backport:
[ruby-core:36051]

Description

In trunk, Float#to_s can produce too many digits.

$ ./miniruby -ve 'puts Float::DIG, 3970 / 3000.0'
ruby 1.9.3dev (2011-05-09 trunk 31491) [x86_64-darwin10.7.0]
15
1.3233333333333333

In the above example, Float::DIG is 15, so the number of significant digits is at most 16.
However, the indefinite 17th digit is produced.

1.9.2 also has this issue.


Related issues 1 (0 open1 closed)

Related to Ruby 1.8 - Backport #3273: Float string conversionClosed05/11/2010Actions

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Open to Rejected

Because they are different values.

$ ruby -e 'p 1.323333333333333 == 3970 / 3000.0'
false
$ ruby -e 'p 1.3233333333333333 == 3970 / 3000.0'
true

Actions

Also available in: Atom PDF