-
Notifications
You must be signed in to change notification settings - Fork 110
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
[Bug]: The precisionRounding: 14
causes the =200.05 - 200
equation to print 0.0500000000000114
instead of 0.05
#1300
Comments
It is caused by the (im)precision of the JavaScript floating-point arithmetics. In most programming languages, calculations that involve fractional numbers are never 100% accurate, e.g. the famous case with 0.1 + 0.2 ≠ 0.3. HyperFormula uses the standard JavaScript implementation of arithmetic operations, which says that
Currently, our documentation says:
with What can we do?
|
After discussing it with @evanSe we decided to apply the documentation changes (points 2 and 3) in the scope of this task. Changing the default value of the config parameter (point 1) will be scheduled for the next major release. |
Changed my opinion on this, changing |
Instead of changing the default value, we will expand the reference to describe the js arithmetic issues better and recommend |
During the internal discussion (https://handsoncode.slack.com/archives/C031GBX62SE/p1721909912700709) we decided, that we WILL change the default value to 10. |
Description
As in the title, if we use
precisionRounding: 14
for the200.05 - 200
calculation we get0.0500000000000114
instead of0.05
value. However, it all works well if we setup theprecisionRounding
to10
.Video or screenshots
No response
Demo
https://codesandbox.io/s/black-lake-wdy2d3?file=/src/hyperformulaConfig.js:123-144
HyperFormula version
2.3.1
Your framework
none
Your environment
Chrome 116 / macOS Ventura
The text was updated successfully, but these errors were encountered: