Menu
Does anybody have any idea why this code wouldn’t give me the correct value for the variable “test”:
var test = Number(5) + Number(12.4) + Number(0) + Number(0.4) + Number(0);
I expect the result to be 17.8, instead I get 17.799999999999997 If I use eval() or parseFloat() instead of Number() the result is the same… I don’t want to round up the number.
I’m really curious why the test code above wouldn’t give me the correct result, and what I should do to get the correct result. Thanks!!!