我不知道该怎么做?我正在添加逗号数字,结果当然总是一个逗号后数字太多的数字。任何人?
EDIT 2:
Use the Number
对象的toFixed
像这样的方法:
var num = Number(0.005) // The Number() only visualizes the type and is not needed
var roundedString = num.toFixed(2);
var rounded = Number(roundedString); // toFixed() returns a string (often suitable for printing already)
将 42.0054321 舍入为 42.01
将 0.005 舍入到 0.01
它将 -0.005 舍入到 -0.01(因此绝对值在 0.5 边界舍入时增加)
jsFiddle 示例
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)