lua浮点数取整

向下取整

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

posted @ 2018-12-20 23:07  随性者也  阅读(34243)  评论(0编辑  收藏  举报