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

猜你喜欢

转载自www.cnblogs.com/zhugaopeng/p/10153059.html