Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <20240623191452.334@kylheku.com>
Deutsch   English   Français   Italiano  
<20240623191452.334@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.c
Subject: Re: The difference between strtol() and strtoul() ?
Date: Mon, 24 Jun 2024 02:29:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <20240623191452.334@kylheku.com>
References: <v51d1l$2fklr$1@news.xmission.com>
 <v540t9$2gsdu$1@news.xmission.com> <20240621182839.00000dc4@yahoo.com>
 <20240621185314.00004fda@yahoo.com> <87o77uqktg.fsf@bsb.me.uk>
 <20240623121952.00005fa9@yahoo.com> <87r0cnq46s.fsf@bsb.me.uk>
 <20240623153219.000009b0@yahoo.com> <87jzifpth6.fsf@bsb.me.uk>
 <864j9jh77d.fsf@linuxsc.com> <87r0cntga9.fsf@nosuchdomain.example.com>
 <87o77rnrt2.fsf@bsb.me.uk>
Injection-Date: Mon, 24 Jun 2024 04:29:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0a91c74ce60a0e44ab75e91b4c3a6a2f";
	logging-data="783840"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+TTlopYa6MQOqNbCEtBQy2Y76/J4w6yvI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:NRZUTuQIObhb6dig5rLIwyZoWMI=
Bytes: 2728

On 2024-06-23, Ben Bacarisse <ben@bsb.me.uk> wrote:
> I don't want to pre-empt Tim's answer, but the wording that bothers me
> is
>
>   "If the subject sequence begins with a minus sign, the value
>   resulting from the conversion is negated (in the return type)."
>
> For strtoll("-9223372036854775808", 0, 0) the value resulting from the
> conversion is 9223372036854775808 which can not even be represented in
> the return type, so how can it be negated "in the return type"?

We have to trust that the specification wants the functions to perform
error checking, rather than precipitate into undefined behavior or
implementation-defined results.

If the negation, which is a positive value, cannot be represented in the
type, that implies it is out of range. The required behavior for a
positive out-of-range value is to return LLONG_MAX and set errno to
ERANGE.

The "in the return type" wording sounds like it may be written that way
to cover the unsigned case, strtoull.

I see in the N3220 draft that the signed and unsigned functions are
lumped together and the wording is now:

"If the subject sequence begins with a minus sign, the resulting value
is the negative of the converted value; for functions whose return type
is an unsigned integer type this action is performed in the return
type."


-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca