Math取整

来源:互联网 发布:天刀网络延迟高 编辑:程序博客网 时间:2024/06/05 16:23

三种取整

Math.ceil()向上取整

Math.floor()向下取整

Math.round()四舍五入




输出结果:

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

原创粉丝点击