From: Tanaka Akira Date: 2013-04-06T07:34:55+09:00 Subject: [ruby-core:54037] Re: [ruby-trunk - Bug #7829] Rounding error in Ruby Time 2013/4/6 David MacMahon : > I understand that the Float returned by Rational#to_f has limited precision and often will only approximate but not equal the value represented by the Rational. But in the example of 57563.232824357045 we are talking about a Float value that is representable. I think it is reasonable to expect f.to_r.to_f == f. I think that this is possible, but it requires changing both Float#to_r and Rational#to_f and I do not have a sense of whether it is practical from a performance point of view. > 57563.232824357045 is not representable as a Float. f.to_r.to_f == f is true. % ruby -e 'f = 57563.232824357045; p "%.1000g" % f, f.to_r.to_f == f' "57563.2328243570445920340716838836669921875" true The actual value of the Float value is 57563.2328243570445920340716838836669921875. -- Tanaka Akira