News for hackers. Stuff that matters.
Re:1.15 * 100 = 149.99999999999999 except in Ruby by gus_massa on Friday December 16, 2011 @12:34PM (#3361351)
The problem is that the decimal numbers in IEEE-754 are approximated by fractions where the denominator is a power of 2. So

  1.15 =~ 5179139571476070 / 2**52 
       =  5179139571476070 / 4503599627370496 
       =~ 1.1499999999999999111821580299875...
And then

  1.15*100 =~ (5179139571476070 / 2**52) * 100  
           =  5179139571476070 / 4503599627370496 *100 
           =~ 114.99999999999999111821580299875...
You can read a more detailed analysis of how .1 is represented in Python in: http://docs.python.org/tutorial/floatingpoint.html

There are no comments on this comment yet.