Issue
Lets say I have an number which is equal to 288.65
and I want to multiply out the decimal point to achieve the desired result of 28865
If I simply just try say console.log(288.65 * 100)
it will return 28864.999999999996
I am not sure why it is doing this, any help will be much appreciated.
Solution
You can use Math.ceil and with Math.round
The Math.ceil() function always rounds a number up to the next largest
integer.The Math.round() function returns the value of a number rounded to the
nearest integer.
const num = 288.65;
const result1 = Math.round(num * 100);
const result2 = Math.ceil(num * 100);
console.log(result1);
console.log(result2);
Answered By – HR01M8055
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0