Liste des Groupes | Revenir à cl c |
On Sun, 23 Jun 2024 12:38:51 +0100
Ben Bacarisse <ben@bsb.me.uk> wrote:
>Michael S <already5chosen@yahoo.com> writes:>
On Fri, 21 Jun 2024 18:15:07 +0100
Ben Bacarisse <ben@bsb.me.uk> wrote:
Michael S <already5chosen@yahoo.com> writes:>
On Fri, 21 Jun 2024 18:28:39 +0300
Michael S <already5chosen@yahoo.com> wrote:
On Fri, 21 Jun 2024 13:58:01 -0000 (UTC)>
gazelle@shell.xmission.com (Kenny McCormack) wrote:
Yeah, now I get it. You really only need strtoimax() and
strtoumax().
Which are? uunfortunately, not part of C standard.
A result of any smaller type can be obtained by calling one of
these functions and storing the result in an object of the
smaller type.
Or check for range and handle out of range values as
appropriate by situation.
BTW, I don't know what The Standard says about out-of-range
inputs, but at least
https://en.cppreference.com/w/c/string/byte/strtol does not say
anything certain. especially about what stored in *str_end.
It says what value should be returned. That's something certain!
In case of strtol, yes.
In case of strtoul it also says what value should be returned, but
plain reading of cppreference.com text (at least *my* plain reading)
does not match observed behaviour. The text on cppreference.com
resembles Standard text, but does not match it.
Ah. What's the discrepancy you see?
IMHO, the Standard texts allows for more interpretations (and
misinterpretations) than cppreference.com text
>Also, at least to me, Standard text itself appear very far from
clear and way too open to interpretations.
My own interpretation would be that for any negative input strtoul()
should return ULONG_MAX and set errno to ERANGE. None of the actual
implementation that I tested behaves in this manner.
I don't get that from the text. There is, after all, no "negative
input". There is a "subject sequence" which, if it starts with a
minus sign, causes the "value resulting from the conversion is
negated (in the return type)" which seems clear enough.
I find it less than clear.
The most non-clear part is that for strtouxx() as long as "subject
sequence" is in range,
it is first converted and then negated. However
when "subject sequence" is out of range it is converted, then clipped
and then *not* negated.
Les messages affichés proviennent d'usenet.