time = Time.now
fvalue = time.to_f
return time == Time.at(fvalue)
Can somebody here explain why the above expression returns false. How can I create a new Time object from float that matches the original time variable?
Thanks
time = Time.now
fvalue = time.to_f
return time == Time.at(fvalue)
Can somebody here explain why the above expression returns false. How can I create a new Time object from float that matches the original time variable?
Thanks
IEEE 754 double (which is returned by
to_f
) is not accurate enough to represent the exact time.Do the following, to preserve the exact time:
Citation from
Time.to_r
: