-
Notifications
You must be signed in to change notification settings - Fork 7
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
Floating Point Rounding #2
Comments
This is an unfortunate side-effect of the fact that computers operate in binary. Any calculation involving floating point numbers have the floating point rounding problem, as it were. See http://floating-point-gui.de/ for more information if you're interested. Try typing the following expression into Google search: Indeed the real problem here is not that the calculations are wrong, it's the fact that Math.js shows too many (all the digits it knows of in fact) digits by default. I suspect the official Calculator app does not show this many digits. Thus, a solution would involve rounding off Math.js decimal answers. |
I see, the stock Calculator app indeed trims the result to show less decimal digits. http://www.isthe.com/chongo/tech/comp/calc/ which is arbitrary precision. |
Since Mather relies quite extensively on Math.js for calculations and expression parsing, we'll probably need to stick with floating-point numbers and just displaying them in a nicer fashion. Thanks for the info though. A quick off-topic question: have you tried unit conversions and such. Just as a quick survey about the importance of #3. |
It seems that arbitrary precision calculations will be implemented in math.js: josdejong/mathjs#694. |
If that happens, we'll inherit that feature :) |
Arbitrary precision fraction support appears to already be available via a configuration option, see http://mathjs.org/docs/core/configuration.html. We will make this available as an option once Settings (#1) is implemented. |
I own a Nexus 6 with stock android, so it's a very standard environment.
I found out that it makes some calculation errors:
1/3 = 0.3333333333333333 (ok)
1 + 1/3 = 1.3333333333333333 (ok)
2 + 1/3 = 2.3333333333333335 (wtf?!)
3 + 1/3 = 3.3333333333333335 (wtf?!)
4 + 1/3 = 4.3333333333333333 (ok again until 7+1/3)
8 + 1/3 = 7.3333333333333334 (?!, goes like this until 15+1/3)
16+1/3 = 7.3333333333333338 (and with this I got bored).
This looks bad.
I did a quick test with the Calculator app from Google and the problem is not present there.
The text was updated successfully, but these errors were encountered: