javascript - Incorrect results in calculations with decimal values with four digits after dot -
this question has answer here:
- is floating point math broken? 20 answers
i have javascript function returns result of multiplications using decimal values (four digits after dot).
but, in conditions, result mess this:
3.9050 * 9 = 35.144999999999996. what should normalize results?
use .tofixed(numberofdecsyouwant)
var num = 3.9050 * 9; console.log(num); //35.144999999999996 console.log(num.tofixed(4)) //35.1450
Comments
Post a Comment