NotsThoughts

xd

Jan 24th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. local abbr = function(num)
  2. local n = string.len(floor(num))
  3. local l = n <= 3 and '' or n <= 6 and 'K' or n <= 9 and 'M' or n <= 12 and 'B' or n <= 15 and 'T' or 'Q'
  4. num = string.format("%.1f",num/10^(math.floor((n-1)/3)*3))
  5. local p = string.find(num,"%.") or 1
  6. p = n <= 3 and p-1 or p == 2 and 4 or p == 3 and 4 or 3
  7. return string.sub(num,0,p) .. l
  8. end
Advertisement
Add Comment
Please, Sign In to add comment