fix rounding to 0 decimal places

This commit is contained in:
Stewart Allen 2022-11-08 22:43:19 -05:00
commit 8c83e1d482
3 changed files with 6 additions and 4 deletions

View file

@ -134,7 +134,9 @@ function inRange(value, min, max) {
}
function round(v, zeros) {
let pow = Math.pow(10, zeros || round_decimal_precision);
const prec = zeros !== undefined ? zeros : round_decimal_precision;
if (prec === 0) return v | 0;
let pow = Math.pow(10, prec);
return Math.round(v * pow) / pow;
}