首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript四舍五入指定精密度

2012-11-23 
javascript四舍五入指定精度function round(num,pos){var num Math.round (num*Math.pow(10,pos))/Math.

javascript四舍五入指定精度
function round(num,pos)
{
var num = Math.round (num*Math.pow(10,pos))/Math.pow(10,pos);
return num;
}


alert(22.6734578656345+" , "+round(22.6734578656345,2)); 1 楼 ileson 2011-04-01   var a=124.45678
a.toFixed(2); 2 楼 zwllxs 2011-04-02   ileson 写道var a=124.45678
a.toFixed(2);

噢,兄弟不早说啊,害我吃力不讨好呀,呵呵

热点排行