NumberFormat: Difference between revisions
Jump to navigation
Jump to search
m LlNumberFormat moved to NumberFormat: LSL pages prefixed with LL are reserved for feature suggestions and official functions. |
mNo edit summary |
||
| Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
=== ''string'' ''' | === ''string'' '''NumberFormat'''(''integer'') === | ||
You can use this to take large numbers and format them to be comma separated by thousands. | You can use this to take large numbers and format them to be comma separated by thousands. | ||
<lsl> | <lsl> | ||
string | string NumberFormat(integer number) | ||
{ | { | ||
string output; | string output; | ||
Revision as of 21:21, 30 March 2008
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
string NumberFormat(integer)
You can use this to take large numbers and format them to be comma separated by thousands. <lsl> string NumberFormat(integer number) {
string output;
integer x = 0;
string numberString = (string)number;
integer numberStringLength = llStringLength(numberString);
integer z = (numberStringLength + 2) % 3;
for(;x < numberStringLength; ++x)
{
output += llGetSubString(numberString, x, x);
if ((x % 3) == z && x != (numberStringLength - 1))
output += ",";
}
return output;
} </lsl>