您的位置:首页 > 其它

Math.floor()/Math.ceil()/Math.round()

2015-12-24 10:18 274 查看
Math.ceil()Math.floor()Math.round()
1.2211
1.5212
1.7212
-1.2-1-2-1
-1.5-1-2-1
-1.7 -1-2-2
Math.ceil()向上取整, Math.floor()向下取整, Math.round()四舍五入。 但是其算法为Math.floor(x + 0.5),所以负数的0.5是舍的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: