Javascript Math ceil()、floor()、round()三个函数的区别

round是四舍五入的,ceiling是向上取整,float是向下取整

alert(Math.ceil(25.9)); //26
alert(Math.ceil(25.5)); //26
alert(Math.ceil(25.1)); //26
alert(Math.round(25.9)); //26
alert(Math.round(25.5)); //26
alert(Math.round(25.1)); //25
alert(Math.floor(25.9)); //25
alert(Math.floor(25.5)); //25
alert(Math.floor(25.1)); //25

你可能感兴趣的:(Javascript Math ceil()、floor()、round()三个函数的区别)