SA-MP Forums Archive
which isnumeric better - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: which isnumeric better (/showthread.php?tid=133568)



which isnumeric better - aircombat - 13.03.2010

i am now on my laptop and i dont have samp server and i can't download it so can anyone tell me which stock of isnumeric is better :

this :
Код:
stock isNumeric(const string[])
{
 new length=strlen(string);
 if (length==0) return false;
 for (new i = 0; i < length; i++)
  {
   if (
      (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
       || (string[i]=='-' && i!=0)                       // A '-' but not at first.
       || (string[i]=='+' && i!=0)                       // A '+' but not at first.
     ) return false;
  }
 if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
 return true;
}
or this:
Код:
stock IsNumeric(const string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	if (string[i] > '9' || string[i] < '0')
  return 0;
	return 1;
}
?


Re: which isnumeric better - pen_theGun - 13.03.2010

first


Re: which isnumeric better - aircombat - 13.03.2010

k thnx for the advice