JavaScript中的Math.ceil()、Math.round()、Math.floor()

1. Math.ceil():向上取整(指取大于该浮点数的最小整数)浮点数

2. Math.round():四舍五入取整(注意:当该浮点数距离两端整数同样时,取较大的那个整数,如Math.round(-1.5)=-1)

3. Math.floor():向下取整(指取小于该浮点数的最大整数)

相关文章
相关标签/搜索