Number separator
#12

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;
}
Reply


Messages In This Thread
Number separator - by Cyboorg - 01.06.2017, 21:07
Re: Number separator - by CheezIt - 01.06.2017, 21:22
Re: Number separator - by Cyboorg - 01.06.2017, 21:28
Re: Number separator - by MattTucker - 01.06.2017, 23:13
Re: Number separator - by Cyboorg - 02.06.2017, 12:22
Re: Number separator - by Dice_ - 02.06.2017, 13:56
Re: Number separator - by Cyboorg - 02.06.2017, 17:54
Re: Number separator - by Dice_ - 02.06.2017, 18:02
Re: Number separator - by CheezIt - 03.06.2017, 03:26
Re: Number separator - by Cyboorg - 03.06.2017, 16:22
Re: Number separator - by Ilias_ - 05.06.2017, 11:13
Re: Number separator - by skuller12 - 05.06.2017, 11:17
Re: Number separator - by CheezIt - 05.06.2017, 18:08
Re: Number separator - by Cyboorg - 05.06.2017, 18:11
Re: Number separator - by skuller12 - 05.06.2017, 18:31
Re: Number separator - by CheezIt - 05.06.2017, 20:38
Re: Number separator - by skuller12 - 05.06.2017, 20:46
Re: Number separator - by JasonRiggs - 05.06.2017, 20:49
Re: Number separator - by GaByM - 05.06.2017, 20:56
Re: Number separator - by Toroi - 05.06.2017, 21:48
Re: Number separator - by Dice_ - 05.06.2017, 22:35
Re: Number separator - by CheezIt - 05.06.2017, 23:43

Forum Jump:


Users browsing this thread: 2 Guest(s)