From: Cameron McBride Date: 2007-11-27T09:51:56+09:00 Subject: Re: Bizarre Floating point errors in Ruby? Serious bug? Samuel, Nothing is amiss. You're just not interpreting the floating point correctly. On 11/26/07, space.ship.traveller@gmail.com wrote: > Hi, > > I've come across a strange bug in ruby (running 1.8.6 on Linux, but > confirmed also in 1.8.5 on an older Mac). > > >> (-140.14 * 100).to_i > => -14013 Not strange at all, look at this: >> puts "%.16f" % (-140.14*100) -14013.9999999999981810 So, when you truncate with the #to_i, you get -14013 -- perfectly consistent and logical. Cameron