【DOM编程艺术】Math对象

Math.ceil(number) 它可以返回大于numbe的值的一个整数。

Math.floor(number) 它可以向小于方向舍入为之最接近的整数。

Math.round(number) 将把任意浮点数舍入为与之最接近的整数。

例如:console.log(Math.ceil(5.2));       console.log(Math.ceil(5.6));      //6     大于
        console.log(Math.floor(5.2));     console.log(Math.floor(5.6));    //5     小于
        console.log(Math.round(5.2));   //5   console.log(Math.round(5.6));  //6   接近

转载于:https://www.cnblogs.com/positive/p/3682522.html

猜你喜欢

转载自blog.csdn.net/weixin_34273481/article/details/93495790