Converting large strings to numbers
- From: rouble@xxxxxxxxx
- Date: 28 Apr 2005 09:32:32 -0700
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
.
- Follow-Ups:
- Re: Converting large strings to numbers
- From: pete
- Re: Converting large strings to numbers
- From: CBFalconer
- Re: Converting large strings to numbers
- From: Eric Sosman
- Re: Converting large strings to numbers
- From: David Resnick
- Re: Converting large strings to numbers
- From: Walter Roberson
- Re: Converting large strings to numbers
- Prev by Date: Re: Yet another book recommendation, but for someone who can program and yet does not the terminology well
- Next by Date: Re: Value of EOF
- Previous by thread: Avoid blocking
- Next by thread: Re: Converting large strings to numbers
- Index(es):
Relevant Pages
|