How do I fix 0.3 + 0.6 = 0.89999999999 in Javascript?
3 answers
Use the BigNumber library. For example math.js has support for bignomes (powered by decimal.js ).
Using the math.js expression parser, you can inject natural expressions using bignomes:
// configure math.js to use bignumbers
math.config({number: 'bignumber'});
// evaluate an expression
math.eval('0.3 + 0.6'); // returns a BigNumber with value 0.9
0
source to share