05.06.2017, 18:08
Quote:
Try this:
Code:
stock FormatNumber(number) { new Str[15]; format(Str, 15, "%d", number); if (strlen(Str) < sizeof(Str)) { if (number >= 1000 && number < 10000 || number >= -1000 && number < -10000) strins( Str, ",", 1, sizeof(Str)); else if (number >= 10000 && number < 100000 || number >= -10000 && number < -100000) strins(Str, ",", 2, sizeof(Str)); else if (number >= 100000 && number < 1000000 || number >= -100000 && number < -1000000) strins(Str, ",", 3, sizeof(Str)); else if (number >= 1000000 && number < 10000000 || number >= -1000000 && number < -10000000) strins(Str, ",", 1, sizeof(Str)),strins(Str, ",", 5, sizeof(Str)); else if (number >= 10000000 && number < 100000000 || number >= -10000000 && number < -100000000) strins(Str, ",", 2, sizeof(Str)),strins(Str, ",", 6, sizeof(Str)); else if (number >= 100000000 && number < 1000000000 || number >= -100000000 && number < -1000000000) strins(Str, ",", 3, sizeof(Str)),strins(Str, ",", 7, sizeof(Str)); else if (number >= 1000000000 && number < 10000000000 || number >= -1000000000 && number < -10000000000) strins(Str, ",", 1, sizeof(Str)), strins(Str, ",", 5, sizeof(Str)), strins(Str, ",", 9, sizeof(Str)); else format(Str, 10, "%d", number); } else format( Str, 15, "<BUG>" ); return Str; } |