New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse_from_f64 is not precise #103
Comments
Yes, this is expected behavior now. The floating point value Putting 20000.000001 into https://baseconvert.com/ieee-754-floating-point confirms this is the correct result: Same with Python's Decimal library:
It's also true for
And I'm sure this is standard behavior for decimal libraries. This is actually the primary reason you use decimal libraries, as the floating point values we are shown are often lies
vs dealing with sums of negative-two powers:
|
This was the previous implementation, which wrote the given number to an allocated string in exponential form with fixed precision:
( Which for your case would parse That implementation was replaced with a couple bit shifts and masks. What specifically broke? Or was this just unexpected behavior? |
Apparently BigDecimal Ruby gem disallows building BigDecimal from float without specifying precision: That doesn't really work for us if we want to keep the trait. |
Ok, thank you for your explanation. That breaks unit tests in my case, nothing critical. |
With the last release (
0.4.0
), this code no longer works:The text was updated successfully, but these errors were encountered: