(1)Math类中提供了三个取整的方法:ceil floor round
ceil 向上取整 Math.ceil(11.3)=12 Math.ceil(-11.3)=-11
floor 向下取整 Math.floor(11.6)=11 Math.floor(-11.6)=-12
round 四舍五入 算法为Math.floor(x+0.5) 即将原来的数字加上0.5 在向下取整
Math.round(11.5)=12 Math.round(-11.5)=-11
(1)Math类中提供了三个取整的方法:ceil floor round
ceil 向上取整 Math.ceil(11.3)=12 Math.ceil(-11.3)=-11
floor 向下取整 Math.floor(11.6)=11 Math.floor(-11.6)=-12
round 四舍五入 算法为Math.floor(x+0.5) 即将原来的数字加上0.5 在向下取整
Math.round(11.5)=12 Math.round(-11.5)=-11