将数字转化成拥有X小数位的形式
1: function roundTo(base,precision)
2: {3: var m=Math.pow(10,precision);
4: var a=Math.round(base*m)/m;
5: return a;
6: }
math.round函数 将数字转化为最接近的整数。
btw:向下取整的函数math.floor 或者math.ceil
1: function roundTo(base,precision)
2: {3: var m=Math.pow(10,precision);
4: var a=Math.round(base*m)/m;
5: return a;
6: }
math.round函数 将数字转化为最接近的整数。
btw:向下取整的函数math.floor 或者math.ceil