购物车计算精度问题

2022-08-07  本文已影响0人  贺大大i

为什么出现精度问题就不多说了,直接上代码

roundFractional(111.15, 2);

 function roundFractional(x, n) {  //x总金额,n保留几位小数
        return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
      }
上一篇 下一篇

猜你喜欢

热点阅读