function changeTwoDecimal(x) {
var f_x = parseFloat(x);
if (isNaN(f_x)) {
return false;
}
f_x = Math.round(f_x * 100) / 100;
return f_x;
}
用法:changeTwoDecimal(3.1415926) 返回 3.14
changeTwoDecimal(3.1475926) 返回 3.15