javascript - Incorrect results in calculations with decimal values with four digits after dot -


this question has answer here:

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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -