function roundUp(num, precision) {
return Math.ceil(num * precision) / precision;
}
var num = 0.07;
var precision = 100;
console.log(roundUp(num, precision));
When the arguments to the function is 0.07 and 100, "num * precision" multiplication gives something like "7.000000000001" and ceil function rounds it up to 8. And I get a completely different result for no reason.
How can I fix this? I have big.js but couldn't work it out.