4 ms·
That happened to me in Ruby, too: http://cl.ly/3x391Q1X2N3k3R030N03 http://cl.ly/3x391Q1X2N3k3R030N03
by goshakkk 15y ago
That happened to me in Ruby, too: http://cl.ly/3x391Q1X2N3k3R030N03 http://cl.ly/3x391Q1X2N3k3R030N03
- kungfooguru 15y agoWeird, I'm on $ irb --version irb 0.9.5(05/04/13) and it gives 115.0: http://i.imgur.com/gGLAd.png http://i.imgur.com/gGLAd.png
- Jacquass12321 15y agoC:\Projects>irb -v irb 0.9.6(09/06/30) C:\Projects>irb irb(main):001:0> 1.15*100 => 114.99999999999999 I don't believe it's a standards issue so much as it is just a facet of floating point math in binary. Since you can't actually store 1.15, you can just store your series of fractions which sum up to something very close to 1.15, I don't have much knowledge of floating point but I'd assume it stops at some value within epsilon of 1.15. When you multiply that value by 100 that sub epsilon value is now large enough to no longer allow the language to automatically round it for display. irb(main):020:0> 1.15*100 > 115-Float::EPSILON => false irb(main):021:0> 1.15*100 > 115-(Float::EPSILON*100) => true I'm assuming older IRB just had a wider acceptance range than epsilon perhaps.
- goshakkk 15y agoMine are Ruby 1.9.3-p0, irb 0.9.6 http://cl.ly/2p1F1Z1Q1N1a38000f1s http://cl.ly/2p1F1Z1Q1N1a38000f1s