Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: formatting integers

Gruff Grut
Registered User
Join date: 13 Jun 2008
Posts: 7
10-19-2008 04:51
I got sick of integers showing up in chat as '1000005' -- i.e. no commas
so, here's a wee function will format integers properly, I'm sure there are slicker versions out there but I can't find them :-)

string format(integer int)
{
string cnumber = (string)int;
string output = "";
integer i;
while ((i=llStringLength(cnumber)) > 3)
{
output = "," + llGetSubString(cnumber, i - 3, -1) + output;
cnumber = (string)((integer)cnumber/1000);
}
return cnumber + output;
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
11-12-2008 06:09
:)
_____________________
i've got nothing. ;)