View Single Post
09-13-09, 04:27 PM   #1166
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
This will do what you want:

Code:
function round(num, idp)
  if idp and idp>0 then
    local mult = 10^idp
    return math.floor(num * mult + 0.5) / mult
  end
  return math.floor(num + 0.5)
end

function CoolNumber(num)
    if num>999 then
        return round(num/1e3,0).."K"
    else
        return num
    end
end
The red number can be 0,1, ... while 0 means 18400 becomes 18k ... 1 means 18400 becomes 18.4k, etc.