I know js calculation is not accurate
But this is really a professional computing class library!!
professional! professional! professional!
Did not even solve!
Use BigNumbers or Fractions instead of numbers
http://mathjs.org/docs/datatypes/numbers.html#roundoff-errors
It needs to be formatted again?!
"npm install mathjs"
"import math form 'mathjs'"
"math.chain().multiply().done() "
look ,Such a perfect code!
Now you tell me, Their results are all wrong by default!
You're just kidding me
I always thought mathjs was a perfect math class library!
JS this problem has existed for so many years
Lots and lots of scattered scripts can solve this
However, we let a default configuration output an error value
WTF take it easy man. Stop talking so aggressively. Take some time to study the issue in-depth before you start screaming.
This is the famous round-off error, which is always there when doing numerical calculations with irrational numbers. There is no free lunch here, it's all about making trade-offs. It's also not a JavaScript problem, it's a generic problem when trying to represent numbers in a computer.
1/3 correctly.In many use cases, working with numbers (having these round-off errors) is just fine: often performance and compatibility matters most, and the numbers may never be displayed on screen making round-off errors a non-issue, or you can easily round them to say 12 digits before displaying end-results to the user.
math.js allows you to simply configure which numeric solution suits you best, which I think is amazing. There are some ideas to make this even better and automatically convert non-BigNumber inputs to BigNumber inputs, see #864.
snoopy83101, if you want to help, be nice. As it is your post is unhelpful and annoying. We are all volunteers here. How do you want to help?
Maybe he can magically solve floating point precision limitations for everyone... maybe he can also invent us some gravity defying cars. Regardless there is no need for unhelpful arrogance.
Most helpful comment
snoopy83101, if you want to help, be nice. As it is your post is unhelpful and annoying. We are all volunteers here. How do you want to help?