From: Marc-Andre Lafortune Date: 2011-09-13T07:38:02+09:00 Subject: [ruby-core:39490] [Ruby 1.9 - Bug #5309] 0.6.to_r != "0.6".to_r Issue #5309 has been updated by Marc-Andre Lafortune. Use `Float#rationalize` instead of `to_r`, and you will get the same result as `String#to_r`. I've argued before that `Float#to_r` should be `Float#rationalize`, though. ---------------------------------------- Bug #5309: 0.6.to_r != "0.6".to_r http://redmine.ruby-lang.org/issues/5309 Author: Brian Ford Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0] 0.6.to_r != "0.6".to_r Is this a bug? $ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0] $ irb ruby-1.9.2-p290 :001 > 0.6.to_r => (5404319552844595/9007199254740992) ruby-1.9.2-p290 :002 > "0.6".to_r => (3/5) ruby-1.9.2-p290 :003 > a = "%.55f" % 0.6 => "0.5999999999999999777955395074968691915273666381835937500" ruby-1.9.2-p290 :004 > b = "%.55f" % "0.6".to_f => "0.5999999999999999777955395074968691915273666381835937500" ruby-1.9.2-p290 :005 > a == b => true Thanks, Brian -- http://redmine.ruby-lang.org