Bug #4135

bug in calculations in 1.9.3dev / 1.9.2

Added by Dmitrii Samoilov over 4 years ago. Updated almost 4 years ago.

[ruby-core:33637]
Status:Rejected
Priority:High
Assignee:-
ruby -v:ruby 1.9.3dev (2010-12-08 trunk 30125) [i686-linux] Backport:

Description

=begin
$ ruby -v
ruby 1.9.3dev (2010-12-08 trunk 30125) [i686-linux]

I just installed ruby-head from rvm and run this in irb:

$ irb
ruby-head > 125.33 - (125.33/100.0*50.0)
=> 62.66499999999999
ruby-head > 125.33 / 100.0 * 50.0
=> 62.665000000000006
ruby-head > 15.33 / 100.0 * 50.0
=> 7.664999999999999
ruby-head > (15.33 / 100.0) * 50.0
=> 7.664999999999999
ruby-head > (14.33 / 100.0) * 50.0
=> 7.165000000000001

Which is obviously wrong.

The same in old ruby 1.9.2.dev

$ ruby -v
ruby 1.9.2dev (2009-07-18 trunk 24186) [i686-linux]
$ irb
ruby-1.9.2-preview1 > (14.33 / 100.0) * 50.0
=> 7.165000000000001

Ruby 1.8.7 looks good
$ ruby -v
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.02

$ irb
irb(main):001:0> (14.33 / 100.0) * 50.0
=> 7.165
=end


Related issues

Related to Ruby trunk - Bug #3746: Incorrect Float subtraction Rejected 08/26/2010

History

#1 Updated by Nobuyoshi Nakada over 4 years ago

  • Status changed from Open to Rejected

=begin

=end

#3 Updated by Dmitrii Samoilov over 4 years ago

=begin
Stupid me. Sorry guys.
=end

Also available in: Atom PDF