var num =2.446242342;
num = num.toFixed(2); // 输出结果为 2.45
Math.floor(15.7784514000 * 100) / 100 // 输出结果为 15.77
Number(15.7784514000.toString().match(/^\d+(?:\.\d{0,2})?/))
// 输出结果为 15.77,不能用于整数如 10 必须写为10.0000
var a = "23.456322";
var aNew;
var re = /([0-9]+.[0-9]{2})[0-9]*/;
aNew = a.replace(re,"$1");
alert(aNew);
var num=22.127456;
alert( Math.round(num*100)/100);
var num = new Number(13.376954);
document.write (num.toFixed(2))
tmp ="3.376954";
result = tmp.substr(0,tmp.indexOf('.')+2);
alert(result);
网友评论