Gary Wright wrote:
[...].
>  
> 
> Many people don't realize that floating point literals written
> in base 10 (such as 123.6) may not have an exact finite
> representation when converted to base 2 

Right. 0.6 in binary has a repeating decimal -- 0.1001 repeating or 
something like that.

> and similarly a finite
> base 2 floating point value may not have a finite representation
> in base 10.
[...]

I think not. Every number of the form 1/(2^n) has a terminating decimal 
in base 10.  Am I wrong?

The problems, of course, arise with numbers like 1/3, which doesn't 
terminate in either base.  This is what the Rational class is good for.

> 
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen / marnen.org
-- 
Posted via http://www.ruby-forum.com/.