js 支持浮点乘法的函数
2021-05-14 13:27
标签:浮点 function math ber pre tip fun string ++ js 支持浮点乘法的函数 标签:浮点 function math ber pre tip fun string ++ 原文地址:https://www.cnblogs.com/yipinGG-8/p/11988324.html/*by xxx*/
accurateMultiply: function () {
var args = arguments,
fixNumber = 1,
n = 0,
arg;
for (var i = 0; i ) {
arg = args[i].toString();
n += (arg.split(‘.‘)[1] ? arg.split(‘.‘)[1].length : 0);
fixNumber = fixNumber * Number(arg.replace(‘.‘, ‘‘));
}
return fixNumber / (Math.pow(10, n));
}