NumberFormat: Difference between revisions
Jump to navigation
Jump to search
Huney Jewell (talk | contribs) m User:Fox Diller/llNumberFormat moved to LlNumberFormat: Move to Wiki |
m lsl code tagging |
||
| Line 3: | Line 3: | ||
=== ''string'' '''llNumberFormat'''(''integer'') === | === ''string'' '''llNumberFormat'''(''integer'') === | ||
You can use this to take large numbers and format it to be comma seperated by thousands. | You can use this to take large numbers and format it to be comma seperated by thousands. | ||
< | <lsl> | ||
string llNumberFormat(integer number) | string llNumberFormat(integer number) | ||
{ | { | ||
| Line 21: | Line 21: | ||
return output; | return output; | ||
} | } | ||
</ | </lsl> | ||
{{LSLC|Examples}} | {{LSLC|Examples}} | ||
{{#vardefine:sort|llNumberFormat}} | {{#vardefine:sort|llNumberFormat}} | ||
Revision as of 16:05, 30 March 2008
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
string llNumberFormat(integer)
You can use this to take large numbers and format it to be comma seperated by thousands. <lsl> string llNumberFormat(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>