I fixed a small bug: when i format -100000 it will return: -,100,000
The fix:
Replace this line in formatnumber.inc
With this:
pawn Код:
if ( ++s_iSepPos == 3 && s_szReturn[s_iChar-1] != '-' )
Test script:
pawn Код:
new i = 0;
while(i < 210000000)
{
i += random(9) + 1;
printf("formatted: %s", FormatNumber(i, 0, ','));
printf("formatted: %s", FormatNumber(i * -1, 0, ','));
i *= 10;
}
Output:
Код:
[17:08:51] formatted: 4
[17:08:51] formatted: -4
[17:08:51] formatted: 46
[17:08:51] formatted: -46
[17:08:51] formatted: 469
[17:08:51] formatted: -,469 <------- ???
[17:08:51] formatted: 4,694
[17:08:51] formatted: -4,694
[17:08:51] formatted: 46,945
[17:08:51] formatted: -46,945
[17:08:51] formatted: 469,455
[17:08:51] formatted: -,469,455 <------- ???
[17:08:51] formatted: 4,694,558
[17:08:51] formatted: -4,694,558
[17:08:51] formatted: 46,945,588
[17:08:51] formatted: -46,945,588
Fixed version:
Код:
[17:09:05] formatted: 3
[17:09:05] formatted: -3
[17:09:05] formatted: 31
[17:09:05] formatted: -31
[17:09:05] formatted: 314
[17:09:05] formatted: -314 <------- fixed
[17:09:05] formatted: 3,146
[17:09:05] formatted: -3,146
[17:09:05] formatted: 31,461
[17:09:05] formatted: -31,461
[17:09:05] formatted: 314,615
[17:09:05] formatted: -314,615 <------- fixed
[17:09:05] formatted: 3,146,158
[17:09:05] formatted: -3,146,158
[17:09:05] formatted: 31,461,582
[17:09:05] formatted: -31,461,582