js四舍五入
js中可以使用Math.round实现整数的四舍五入,如果需要实现精确到小数点多少位则需要编写函数了。
function ForDight(Dight,How) {
Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);
return Dight;
}
本文转载自<这一技客> http://www.geekso.com/
js中可以使用Math.round实现整数的四舍五入,如果需要实现精确到小数点多少位则需要编写函数了。
function ForDight(Dight,How) {
Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);
return Dight;
}
本文转载自<这一技客> http://www.geekso.com/