Converting large strings to numbers



Without using errno, is there a portable way to detect if a string
number is not within the range 0 to 4294967295.

Currently I am using strtoul. I can check the string for "-" as the
first character before calling strtoul, so I can figure out if the
value is less than 0.

My issue arises when the number is greater than 4294967295 on platforms
where ULONG_MAX is 4294967295; in this case strtoul will return
ULONG_MAX and set errno to ERANGE. However, some platforms I work on do
not support errno. So there is no way for me to know that the value was
greater than 4294967295.

Is there another way to do this ?

TIA,
rouble

.



Relevant Pages

  • Re: strtoul bug (was Fibonacci number)
    ... and that the string is then parsed up to the ... But errno should be set to ERANGE for all ... > you take the step of accepting modulo arithmetic from strtoul. ...
    (comp.lang.c)
  • Re: strtoul bug (was Fibonacci number)
    ... >> I would suggest that the proper interpretation of that string is ... > interpretation would make sense if we start defining the strtoul ... Since that would be a quiet change for working ... But errno should be set to ERANGE for all ...
    (comp.lang.c)
  • Re: Converting large strings to numbers
    ... is there a portable way to detect if a string ... > first character before calling strtoul, so I can figure out if the ... > ULONG_MAX and set errno to ERANGE. ... some platforms I work on do ...
    (comp.lang.c)
  • Re: Converting large strings to numbers
    ... is there a portable way to detect if a string ... > return ULONG_MAX and set errno to ERANGE. ... However, some platforms I ... and if you need string input make the ...
    (comp.lang.c)
  • Re: Converting large strings to numbers
    ... > first character before calling strtoul, so I can figure out if the ... > ULONG_MAX and set errno to ERANGE. ... some platforms I work on ... Well, if strtoul returns ULONG_MAX, you could compare the string being ...
    (comp.lang.c)