Article View: comp.std.c
Article #2171Re: strtoul on negative numbers
From: Michael Henning
Date: Wed, 30 Sep 1992 23:48
Date: Wed, 30 Sep 1992 23:48
27 lines
1413 bytes
1413 bytes
jss@lucid.com (Jerry Schwarz) writes:
>What is the result of
>
> strtoul("-2", (char**)0, 10)
>The description is clear that the minus sign is allowed.
>The relevant sentence describing the result is.
>
>"If the correct value is outside the range of representable values
>ULONG_MAX is returned ..."
>My reading of this is that it requires ULONG_MAX to be returned,
>but others think that -2 is a representable value (equal to
>ULONG_MAX-1) and so ULONG_MAX-1 should be returned.
All implementations I have seen return ULONG_MAX - 1.
I believe that this is incorrect behaviour.
-2 is not a value representable in an unsigned long, in my opionion.
Michi.
--
-m------- Michael Henning +61 75 950255
---mmm----- Pyramid Technology +61 75 722475 FAX
-----mmmmm--- Research Park, Bond University michi@ptcburp.ptcbu.oz.au
-------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi
Technical Details
Message-ID:
<1992Sep30.234808.19678@ptcburp.ptcbu.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sgiblab!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!lance!ptcburp!michiReferences:
<1992Sep30.175835.7972@lucid.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sgiblab!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!lance!ptcburp!michi From: michi@ptcburp.ptcbu.oz.au (Michael Henning) Newsgroups: comp.std.c Subject: Re: strtoul on negative numbers Message-ID: <1992Sep30.234808.19678@ptcburp.ptcbu.oz.au> Date: 30 Sep 92 23:48:08 GMT References: <1992Sep30.175835.7972@lucid.com> Organization: Pyramid Technology Corporation Lines: 27