//toFixed 四舍五入遇到坑。1.235.toFixed(2) = 1.231.2350001.toFixed(2) = 1.24 //去尾法Number.prototype.toFloor = function (num) {return Math.floor(this * Math.pow(10, num)) / Math.pow(10, num);};//进一法Number.prototype.toCeil = function (num) {return Math.ceil(this * Math.pow(10, num)) / Math.pow(10, num);};//四舍五入法Number.prototype.toRound = function (num) {return Math.round(this * Math.pow(10, num)) / Math.pow(10, num);};
JS保留小数 去尾法 进一法 四舍五入法
原文地址:https://www.cnblogs.com/LChenglong/p/9170334.html