18.09.2010, 18:48
(
Последний раз редактировалось RyDeR`; 07.09.2011 в 15:44.
)
Info
This function converts a number to a string seperated with commas.
Function
Example
will become:
Note
Please note that you can't go over value 2147483647 because that's the integer limit; I also have no idea how to increase. An altirnative solution is to use the value as a string.
This function converts a number to a string seperated with commas.
Function
pawn Код:
stock FormatNumber(iNum, const szChar[] = ",")
{
new
szStr[16]
;
format(szStr, sizeof(szStr), "%d", iNum);
for(new iLen = strlen(szStr) - 3; iLen > 0; iLen -= 3)
{
strins(szStr, szChar, iLen);
}
return szStr;
}
pawn Код:
printf("%s", FormatNumber(50000000));
pawn Код:
"50,000,000"
Please note that you can't go over value 2147483647 because that's the integer limit; I also have no idea how to increase. An altirnative solution is to use the value as a string.