特别注意parseInt()是js全局函数,(习惯(java的方式)integer.parseInt()会报错!)
1,Math.ceil()方法向上取整,整数部分值+1: Math.ceil(3/2) 输出:2 2,Math.floor()方法向下取整,整数部分值不变: Math.floor(3/2) 输出:1 3,Math.round()方法四舍五入取整: Math.round(3/2) 输出:2 4,parseInt()方法 抛去小数部分,只取整数部分: parseInt(3/2) 输出:1
把数字转换为字符串,结果的小数点后有指定位数的数字: var num = 5.56789; var n=num.toFixed(2);(Number对象的方法) n 输出结果:5.57