本文 18067 pv
1
下面是一个实现小数点后指定精确位数四舍五入的函数,与君共享。
function ForDight(Dight,How) {
Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);
return Dight;
}
js四舍五入
© kekehu / 技术资源 / 2008.11.19 / 14:56 / 18067PV
js中可以使用Math.round实现整数的四舍五入,如果需要实现精确到小数点多少位则需要编写函数了。下面是一个实现小数点后指定精确位数四舍五入的函数,与君共享。
function ForDight(Dight,How) {
Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);
return Dight;
}
2013.03.13 09:26
灰常感謝。。。