本文 18067 pv

1

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;
}    

本文有 1 篇评论

  1. @ this is why 说 :
    2013.03.13 09:26
    avatar

    cool灰常感謝。。。

1/1 第一页 1 最后页

发表你的见解

打开HTML 打开UBB 打开表情 隐藏 记住我
emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemot