So, I want a number to show only a specified amount of decimal.
For example:
local function showDecimals(number, amountOfDecimals)
--code
end
showDecimals(123456, 3)
So, I want a number to show only a specified amount of decimal.
For example:
local function showDecimals(number, amountOfDecimals)
--code
end
showDecimals(123456, 3)
Do you mean the number of decimal places? If so you can use string.format with the .
precision specifier.
local function showDecimals(number, amountOfDecimals)
return string.format(`%.{amountOfDecimals}f`, number)
end
print(showDecimals(123456, 3)) --> 123456.000
like if amountOfDecimals was 2 then 4,543.4238 = 4,543.42
just found out that works!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.