Bugs item #10935, was opened at 2007-05-20 20:13
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10935&group_id=426

Category: Core
Group: 1.8.x
Status: Open
Resolution: None
Priority: 3
Submitted By: Boris Schmid (bor_)
Assigned to: Nobody (None)
Summary: eval("0.0025 + 9 * 0.0025") === 0.025  => false

Initial Comment:
Eval is being (inconsistently) strange. 

It's acting normal when I do the (8 * 0.0025) example, and not acting normally when I do the (9 * 0.0025) example. Plenty of other combinations where it repeatedly does the same.


boris:alive:~:irb
irb(main):001:0> eval("0.0025 + 9 * 0.0025")
=> 0.025
irb(main):002:0> eval("0.0025 + 9 * 0.0025") === 0.025
=> false
irb(main):003:0> eval("0.0025 + 8 * 0.0025")
=> 0.0225
irb(main):004:0> eval("0.0025 + 8 * 0.0025") === 0.0225
=> true
irb(main):005:0> exit
boris:alive:~:ruby -v
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux]


Same for ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]
Same for ruby 1.8.6 (2006-12-25 patchlevel 12) [i386-mswin32]

For windows ruby 1.8.6, the below sample give some more insight into the bug:

irb(main):001:0> eval("1 + 9 * 1")
=> 10
irb(main):002:0> eval("1 + 9 * 1") === 10
=> true
irb(main):003:0> eval("0.1 + 9 * 0.1")
=> 1
irb(main):004:0> eval("0.1 + 9 * 0.1") === 1
=> true
irb(main):005:0> eval("0.01 + 9 * 0.01") === 0.1
=> false
irb(main):006:0> exit


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10935&group_id=426