2013/4/4 David MacMahon <davidm / astro.berkeley.edu>:
>
>>> f=57563.232824357045
> => 57563.232824357045
>
>>> puts "%016x\n"*5 % [f, f.to_r.to_f, f.to_s.to_f, f.to_s.to_r.to_f, f.rationalize.to_f].pack('D*').unpack('Q*')
> 40ec1b67734c10e7
> 40ec1b67734c10e7
> 40ec1b67734c10e7
> 40ec1b67734c10e6 <=== String#to_r "error"
> 40ec1b67734c10e7
> => nil

I don't think that String#to_r is wrong.

% ruby -e 'f=57563.232824357045
p f, f.to_s, f.to_s.to_r
'
57563.232824357045
"57563.232824357045"
(11512646564871409/200000000000)

String#to_r is correct because
57563.232824357045 == 11512646564871409/200000000000 in mathematical sense.

The "error" is caused by Froat#to_s and it is expected.

> I regard the String#to_r error to be a bug (i.e unintended and undesirable behavior).

I don't think so.

> I find the Float#rationalize error to be undesirable behavior (IMHO), but since the documentation is vague I can't really say that it is unintended behavior.

I have no idea about Float#rationalize.

Anyway, I'm sure now that Float#rationalize should not be used
internally/automatically.

Anyone can use it as Time.utc(1970,1,1,0,0,12.860.rationalize) and it
may (or may not) solve problem, though.
-- 
Tanaka Akira