引用:https://www.jb51.net/article/85463.htm
其实精度问题的发生概率很低,
另外,调整精度问题的应放在数据计算结束后在处理,先乘以100取整(Math.round)再除于100,得到两位小数的整数,此时精度问题也解决了。
var initial=num;
var res = Math.round(initial*100)/100
引用:https://www.jb51.net/article/85463.htm
其实精度问题的发生概率很低,
另外,调整精度问题的应放在数据计算结束后在处理,先乘以100取整(Math.round)再除于100,得到两位小数的整数,此时精度问题也解决了。
var initial=num;
var res = Math.round(initial*100)/100