iBuzzes
(Silly_Ryan)
#1
How to round a number to 2 decimal places?
For example, if the number is:
0.628321
then it would become:
0.62
1 Like
Volieb
(Vinny)
#2
Hi there! This is how you would achieve this:
local places = 2 -- the amount of decimal places
local number = 0.628321
local mult = 10^places
number=math.floor(number*mult)/mult -- 0.62
7 Likes
Forummer
(Forummer)
#3
With math:
print(math.round(number * 100)/100)
Without math:
print(string.format("%.2f", number))
6 Likes
sau2000
(sau2000)
#4
The way @Volieb mentioned works but I would this module.