I have following value which give wrong total.
let a = 86.2500;
let b = 32.3550;
alert(a+b); //return 118.60499999999999 , expected 118.605
alert((a+b).toFixed(2)) //return 118.60 , expected 118.61
When I calculate above value with my calculator it give my expected result but javascript give me unexpected result. Why and what is solution to get expected result?
No comments:
Post a Comment