为什么出现精度问题就不多说了,直接上代码
roundFractional(111.15, 2);
function roundFractional(x, n) { //x总金额,n保留几位小数
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
}
为什么出现精度问题就不多说了,直接上代码
roundFractional(111.15, 2);
function roundFractional(x, n) { //x总金额,n保留几位小数
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
}