You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fread occasionally reads in differently rounded non-exact fp numbers than base R #4461
This is likely a non-issue (I do understand that these numbers are not meaningfully different). And Apologies if I missed mention of this in the documentation or prevoius issues (I did look).
There are certain values (I ran into one in the wild) where fread and read.table (which agrees with R's parser) parse a string representing a floating point number into equivalent but non-identical byte-representations.
Note this will mean that caching cannot be trusted to stay non-stale when upgrading read.table calls to fread, where the docs and a naive-understanding of what is happening would suggest they could.
Activity
MichaelChirico commentedon May 20, 2020
Confirmed on master, which means that #4165 doesn't solve this
MichaelChirico commentedon May 20, 2020
seven31is helpful here -- there's an off-by-one error:Also FWIW i tried to figure out the closest representable number to
0.8060667366and IINM theexnumvalue is the right oneMichaelChirico commentedon May 20, 2020
The discrepancy happens here:
MichaelChirico commentedon May 20, 2020
The parser seems to be accurate about 99.99% of the time:
And there's something of a pattern in the erroneous cases:
mattdowle commentedon Aug 27, 2021
Great investigation and fix @MichaelChirico!
Btw, I would have thought positive powers of 10 up to 10^15 could be stored precisely because 2^52 ~ 4.5e15 (all integers up to that value can be stored precisely). But apparently it's up to 10^22 : https://www.exploringbinary.com/why-powers-of-ten-up-to-10-to-the-22-are-exact-as-doubles/