Javascript Arithmetic is not always accurate, and such erroneous answers are not unusual. I would suggest that you use Math.Round() or var.toFixed(1) for this scenario.
Using Math.Round:
var value = parseFloat(50) * parseFloat(2.3659); var rounded = Math.round(value); console.log(rounded);
Prints 118 on the console.
Using the toFixed () method:
var value = parseFloat(50) * parseFloat(2.3659); var rounded = value.toFixed(1); console.log(rounded);
Prints 118.3 on the console.
Note that using toFixed(2) will give a value as 118.29 .
Hope this helps!
source share