print(math.floor(12.5928))
The code above prints 12. What do you do to make it print 12.5?
print(math.floor(12.5928 * 10) / 10)
To generalize the previous answer, this function rounds a number to any number of decimals:
function round(number, decimals)
local power = 10^decimals
return math.floor(number * power) / power
end
Then, round(12.5928, 1)
gives 12.5
.
print(string.format("%.2f", 129.65686))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With