[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Hex numbers
- From: Carlos Augusto Teixeira Mendes <cmendes@...>
- Date: Tue, 29 Aug 2000 10:51:33 -0300
> n = strtol(&s[2], &ss,base);
> if (ss != &s[2])
> return (double)n;
> else
> return -1;
> }
> // End Hex
I belive this will accept wrong numbers...
Ex: s="0xA0XF"
n = strtol(&s[2], &ss, 16) whil produce:
n = 160 (A0) and ss = "XF"
I belive a simple change can solve that (UNTESTED):
if(!s[2])
return -1;
n = strtol(&s[2], &ss, base);
if(!(*ss))
return -1;
else
return (double)n;
[]s,
Carlos Augusto.