首页 > 其他 > 详细

Math.round(),Math.ceil(),Math.floor()的区别

时间:2019-12-10 19:18:52      阅读:93      评论:0      收藏:0      [点我收藏+]

Math.round()

round 附近 四舍五入 取附近的整数

Math.round(11.5)=12
Math.round(11.4)=11
Math.round(-11.6)=-12
Math.round(-11.4)=-11

Math.ceil()

ceil 天花板 取大于当前小数的整数

Math.ceil(11.2)=12
Math.ceil(-11.5)=-11

Math.floor()

floor 地板 取小于当前小数的整数

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

??

Math.round(),Math.ceil(),Math.floor()的区别

原文:https://www.cnblogs.com/xiaoyinger/p/12018146.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!