04.02.2011, 13:48
-1 is not numeric!
Also, why would you keep looping if you find an invalid number?
Proper version would be (I stole this from myself):
Also, why would you keep looping if you find an invalid number?
Proper version would be (I stole this from myself):
pawn Код:
stock bool:IsValidNumber( const szString[ ] )
{
if ( !szString[ 0 ] )
return false;
new
iLength = strlen( szString ),
i
;
if ( szString[ 0 ] == '-' && szString[ 1 ] )
i = 1;
for ( ; i < iLength; i++ )
{
if ( !( '0' <= szString[ i ] <= '9' ) )
return false;
}
return true;
}