10.08.2011, 20:53
hm here is a IsFloat function I just created..
no clue if someone already posted one here, however here it is
as far as I've tested it it works good
no clue if someone already posted one here, however here it is
as far as I've tested it it works good
pawn Код:
stock IsFloat(buf[])
{
new l = strlen(buf);
new dcount = 0;
for(new i=0; i<l; i++)
{
if(buf[i] == '.')
{
if(i == 0 || i == l-1) return 0;
else
{
dcount++;
}
}
if((buf[i] > '9' || buf[i] < '0') && buf[i] != '+' && buf[i] != '-' && buf[i] != '.') return 0;
if(buf[i] == '+' || buf[i] == '-')
{
if(i != 0 || l == 1) return 0;
}
}
if(dcount == 0 || dcount > 1) return 0;
return 1;
}