Florian G. Pflug schrieb:

>
> That a neat way of extracting the exponent! ;-)
>
> Be carefull, howevery - this will not always give
> the expected results. Try e.g.
>
> puts (0.2).to_r
>
> This yields: 3602879701896397/18014398509481984
> which of course is nearly 2/5, but since
> 0.2 has infinitly many digits when converted
> to a binary representation, a rounding error occurs.


For serious use he'd probably better using  "continued fractions" based
conversion algorithm (check out any googled side with this search term)
+  error term

def to_r(eps = 10**(-13))
    ...
end


/Christoph