i've the following code in Javascript:
var m1 = 2232.00;
var percent = (10/100);
var total = percent*m1;
alert(total);
The problem is that the variable "total" gives me "223.20000000000002" and it should be "223.2", what should i do to get the correct value?
.toFixed() is best solution.It will keep only two digits after dot.
Exp 1:
var value = 3.666;
value.toFixed(2); //Output : 3.67
Exp 2:
var value = 3.0000;
value.toFixed(2); //Output : 3.00