I don’t think there is an automatic format for this so you have to do it manually. The quickest way I found was like so:
function abbreviateNumber(number)
local digitsPassedBil = number / 1000000000
local suffix = ""
if digitsPassedBil >= 1 then
suffix = "B"
end
if digitsPassedBil >= 1000 then
digitsPassedBil /= 1000
suffix = "T"
end
if digitsPassedBil >= 1000 then
digitsPassedBil /= 1000
suffix = "q"
end
print(tostring(digitsPassedBil)..suffix)
return tostring(digitsPassedBil)..suffix
end
Add if statements for more suffixes and only change the suffix in the if statement.
function formatNumber(n)
if n >= 10^6 then
return string.format("%.2fm", n / 10^6)
elseif n >= 10^3 then
return string.format("%.2fk", n / 10^3)
else
return tostring(n)
end
end
You have to add more values as you go higher. Ensure it’s ordered from highest to lowest. This example uses millions and thousands, with 2 decimal points.