Skip to content
On this page

数字四舍五入

javascript
/**
 * 对数字进行四舍五入,可精确小数点位置
 */
function round(number, precision) {
    return Math.round(+number + 'e' + precision) / Math.pow(10, precision);
}