您的位置:首页 > 其它

Math.round(11.5)等于多少?Math.round(-11.5)等于多少?

2015-06-08 09:16 232 查看
Math类提供的几个常用的方法就是 Math.ceil(x); Math.floor(x); Math.round(X);Math.random();等等。

ceil 顾名思义,天花板,就是向上取整咯。

floor 地板 就是向下取整了

最后 Math.round(x)这个有点小小的繁琐: Math.round(x)=Math.floor(x+0.5);

所以 Math.round(11.5)等于12

Math.round(-11.5)等于11
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: