三种取整

Math.ceil()向上取整

Math.floor()向下取整

Math.round()四舍五入

Math取整



输出结果:

Math.floor(11.5)= 11.0
Math.floor(-11.5)= -12.0
Math.ceil(11.5)= 12.0
Math.ceil(-11.5)= -11.0
Math.round(11.5)= 12
Math.round(-11.5)= -11

相关文章: