标签:
function toDecimal(x) {
var f = parseFloat(x);
if (isNaN(f)) { return; } //isNaN判断传入的数字是否有效
f = Math.round(x*100)/100; 先执行Math.round(x*100)
return f;
}
四舍五入保留两位小数
原文地址:http://www.cnblogs.com/samtrybest/p/5077757.html