print(math.floor(12.5928))
上面的代码打印12.你怎么做才能打印12.5?
print(math.floor(12.5928 * 10) / 10)
为了概括先前的答案,此函数将数字四舍五入为任意数量的小数:
function round(number, decimals)
local power = 10^decimals
return math.floor(number * power) / power
end
然后,round(12.5928, 1)
给12.5
。
两位数的打印(math.floor((12.5928)* 100)/ 100)
print(string.format(“%。2f”,129.65686))