javascript四舍五入保留n位小数

  function toFixed (num, n)// 四舍五入保留n位小数
        {
            if (!isNaN(num)) {
                var multiple = Math.pow(10, n);
                return Math.round(num * multiple) / multiple; 
            }else{
                return num
            }
        }

猜你喜欢

转载自weibin529.iteye.com/blog/2274235