Created
July 15, 2011 17:55
-
-
Save donpdonp/1085169 to your computer and use it in GitHub Desktop.
floating point crazyness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb | |
irb(main):001:0> RUBY_VERSION | |
=> "1.9.2" | |
irb(main):002:0> 1.8 + 0.1 | |
=> 1.9000000000000001 | |
irb(main):003:0> 1.8 + 0.1 == 1.9 | |
=> false | |
irb(main):004:0> | |
## Ruby 1.8 wont even let you know whats going on! | |
ree-1.8.7-2011.03 :008 > RUBY_VERSION | |
=> "1.8.7" | |
ree-1.8.7-2011.03 :009 > 1.8 + 0.1 | |
=> 1.9 | |
ree-1.8.7-2011.03 :010 > 1.8 + 0.1 == 1.9 | |
=> false | |
ree-1.8.7-2011.03 :011 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It'd be nice if it could keep track of significant figures or something and round off the noise at the end. Maybe that's what that MPFR library is for. I just wish things like Decimal and Rational were as small and quick as Float.