修复小数计算精度不准确方法
Number.prototype.mul = function (arg) { var m = 0, s1 = this.toString(), s2 = arg.toString(); try { m += s1.split('.')[1].length } catch (e) { } try { m += s2.split('.')[1].length // m是累加结果 } catch (e) { } return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m) // 直接去掉小数点,转为整型计算,最后缩小n倍 }; function louis(arg){ var m=0, s1 = arg.toString(); try { m = s1.split('.')[1].length; } catch (e) { } return Number(s1.replace('.',''))/Math.pow(10,m-2) };