From: Edgardo Hames Date: 2004-10-29T03:58:00+09:00 Subject: Re: Rounding error, (100.0 * 9.95).to_i == 994 On Fri, 29 Oct 2004 02:40:14 +0900, Guillaume Marcais wrote: > On Thu, 2004-10-28 at 04:23, Mark Hubbart wrote: > > Another funny failing of the notation is that not everything that looks > like a number actually represents a number. The following is quite > intriging: > > x = 0.99999... (infinite serie of 9s) > 10*x = 9.99999... > 10*x - x = 9*x = 9 > So x = 1! 0.9999... (infinite serie of 9s) is the standard (not IEEE, but plain math) of the real number 1. Do you remember how to transform a periodic number to a quotient? That's the integer part of the number plus (the periodical part divided by as many nines as the periodical part's digits). For example: 1.333... = 1 + 3/9 8.577577577... = 8 + 577/999 So, 0.99999... = 0 + 9/9 which is clearly 1. Regards, Ed -- Despite the surge of power you feel upon learning Ruby, resist the urge to trip others or slap them in the bald head. DO NOT LORD YOUR RUBYNESS OVER OTHERS!