Math类基本函数:floor、ceil、round方法


floor : 意为地板,指向下取整,返回不大于它的最大整数
ceil : 意为天花板,指向上取整,返回不小于它的最小整数
round : 意为大约,表示“四舍五入”,而四舍五入是往大数方向入。

Math.round(11.5)的结果为12,
Math.round(-11.5)的结果为-11而不是-12。

猜你喜欢

转载自blog.csdn.net/qq_41953807/article/details/89532117