Math.ceil()和 Math.floor() 的区别
参考答案
Math.ceil:向上取整(→ 更大的整数方向),Math.ceil(1.1)=2、Math.ceil(-1.1)=-1Math.floor:向下取整(→ 更小的整数方向),Math.floor(1.9)=1、Math.floor(-1.1)=-2
一句话:ceil 是"天花板"往上,floor 是"地板"往下;负数的结果与直觉常相反。
常用于分页:totalPage = Math.ceil(total / size)。