打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Math.round(),Math.ceil(),Math.floor()的区别

1.Math.round():“round”:“四周”,该函数是求一个附近的整数。

小数点后第一位<5
正数:Math.round(11.22)=11
负数:Math.round(-11.22)=-11

小数点后第一位>5
正数:Math.round(11.66)=12
负数:Math.round(-11.66)=-12

小数点后第一位=5
正数:Math.round(11.5)=12
负数:Math.round(-11.5)=-11
总结:(小数点后第一位)大于五全部加,等于五正数加,小于五全不加。

2.Math.ceil():“ceil”:“天花板”

Math.ceil(11.22)=Math.ceil(11.66)=Math.ceil(11.5)=12
Math.ceil(-11.22)=Math.ceil(-11.66)=Math.ceil(-11.5)=-11

3.Math.floor():“floor”:“地板”

Math.floor(11.22)=Math.floor(11.66)=Math.floor(11.5)=11
Math.floor(-11.22)=Math.floor(-11.66)=Math.floor(-11.5)=-12

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Python 之 向上取整、向下取整以及四舍五入函数
js函数Mathrandom()、ceil()、floor()、round()比较
AS3.0--数学函数
JAVA取整
php小数取整的方法
Delphi取整函数
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服