首页 > 其他 > 详细

lua浮点数取整

时间:2018-12-20 23:41:39      阅读:912      评论:0      收藏:0      [点我收藏+]

向下取整

math.floor(num)

向上取整

math.ceil(num)

取整取余

math.modf(num)

测试

num = 12.4
print(math.floor(num)) 12
print(math.ceil(num)) 13

integer, decimal = math.modf(num)
print(integer) 12
print(decimal) 0.4

lua浮点数取整

原文:https://www.cnblogs.com/zhugaopeng/p/10153059.html

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