数字精度

引用:https://www.jb51.net/article/85463.htm

其实精度问题的发生概率很低,

另外,调整精度问题的应放在数据计算结束后在处理,先乘以100取整(Math.round)再除于100,得到两位小数的整数,此时精度问题也解决了。

var initial=num;

var res = Math.round(initial*100)/100

猜你喜欢

转载自my.oschina.net/u/3272730/blog/1839259