After a few number of decimal places

Retention function of several decimal places

function xround(x, num) {
    x = parseFloat(x);
    num = parseInt(num);
    return Math.round(x * Math.pow(10, num)) / Math.pow(10, num);
}

 

Guess you like

Origin www.cnblogs.com/hool/p/11725659.html