I am wanting to turn a number into an abbreviated number (example, 3.5K+), however, I’m not sure how I can find the second number (5). The second number is represented by second
in the code below.
Here are examples of what I mean:
450,300 = 450.3K+
100,500,430,500 = 100.5B+
54,300,201 = 54.3M+
Here is the code:
function Math:Abbreviate(number)
if number < 1000 then
return tostring(number)
end
local digits = math.floor(math.log10(number)) + 1
local index = math.min(#Abbreviations, math.floor((digits - 1) / 3))
local front = number / math.pow(10, index * 3)
local second = --Help Here
return string.format("%i.%d%s+", front, second, Abbreviations[index])
end
Any help is appreciated, thank you!