Sujet : Re: The difference between strtol() and strtoul() ?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 21. Jun 2024, 18:50:40
Autres entêtes
Organisation : None to speak of
Message-ID : <87zfreuqvj.fsf@nosuchdomain.example.com>
References : 1 2 3
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Michael S <
already5chosen@yahoo.com> writes:
On Fri, 21 Jun 2024 13:58:01 -0000 (UTC)
[...]
I implementation that I just tested strtoll and strtull are not the
same. They deliver different answers when input is out of range.
Yes, that's the required behavior. N1570 7.22.1.4p8:
"""
The strtol, strtoll, strtoul, and strtoull functions return the
converted value, if any. If no conversion could be performed, zero is
returned. If the correct value is outside the range of representable
values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX, ULONG_MAX, or
ULLONG_MAX is returned (according to the return type and sign of the
value, if any), and the value of the macro ERANGE is stored in errno.
"""
N3220 has identical wording in 7.24.1.7p8. The wording for strtoimax
and strtoumax (<inttypes.h>) is equivalent.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */