commarising numbers

If I have a really large number (in the tens of millions) how would I go about displaying it with commas?
For example 12,345,678 instead of 12345678.

…and yes I know commarising isn’t a real word :slight_smile:
[import]uid: 7841 topic_id: 22364 reply_id: 322364[/import]

Hey, Appletreeman, I use this function. See below.

Naomi

-- copied from http://lua-users.org/wiki/FormattingNumbers  
-- comma\_value(1000) will return 1,000 which is a string.  
local function comma\_value(amount)  
 local formatted = amount  
 while true do   
 formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')  
 if (k==0) then  
 break  
 end  
 end  
 return formatted  
end  

[import]uid: 67217 topic_id: 22364 reply_id: 89151[/import]