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

@ -253,6 +253,7 @@ Math.bound = function(val, min, max) {
};
Number.prototype.round = function(digits) {
if (digits === 0) return this.valueOf() | 0;
const pow = Math.pow(10, digits || 3);
return Math.round(this.valueOf() * pow) / pow;
};