Project

General

Profile

Actions

Backport #1910

closed

BigDecimal addition inaccuracy 3.6525+24.35 != 28.25

Added by eliotsykes (Eliot Sykes) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
[ruby-core:24819]

Description

=begin
ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-linux]

I tried this sum and got the answer 28.25 instead of 28.0025:

result = BigDecimal.new("3.6525") + BigDecimal.new("24.35")
puts result.to_f

Prints "28.25" instead of "28.0025"
=end

Actions #1

Updated by eliotsykes (Eliot Sykes) over 14 years ago

=begin
Further research shows this issue may have been fixed in p174:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/338957

From the changelog:

Fri Jun 12 16:36:44 2009 Yukihiro Matsumoto

* ext/bigdecimal/bigdecimal.c (VpToString): fixed a bug introduced
  in r23613.  [ruby-talk:338957]

=end

Actions #2

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

  • Status changed from Open to Closed

=begin
... and has been backported to 1.8.7-p174. Get a newer version.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0