From: Florian Gross Date: 2004-10-28T05:09:02+09:00 Subject: Re: Rounding error, (100.0 * 9.95).to_i == 994 Jason DiCioccio wrote: > I'm confused now.. 100.0 * 9.95 is clearly 995. So what exactly is the > issue with floating point numbers is making this come out to > 994.999999999983 (or wahtever ;))? If every language is plagued by this > problem, then I'd be curious to know the history behind it.. Floating point numbers are expressed in base 2. 9.95 has an infinite number of digits in base 2 representation just like the result of 1/3 has in base 10. However floating point numbers clearly can't be stored with an infinite amount of bits which is why the above gets slightly imprecise. You can have a look at all the digits of a float like this: irb(main):172:0> "%.32f" % 9.95 => "9.94999999999999930000000000000000"