Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Your fault -- core dumped


devel / comp.lang.c / Re: C99: 7.18.1.1 Exact-width integer types

SubjectAuthor
* C99: 7.18.1.1 Exact-width integer typesMeredith Montgomery
+* Re: C99: 7.18.1.1 Exact-width integer typesKeith Thompson
|`- Re: C99: 7.18.1.1 Exact-width integer typesKeith Thompson
+- Re: C99: 7.18.1.1 Exact-width integer typesJames Kuyper
`- Re: C99: 7.18.1.1 Exact-width integer typesDavid Brown

1
C99: 7.18.1.1 Exact-width integer types

<86k0emc9ga.fsf@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20228&group=comp.lang.c#20228

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!3E/HvDozwKlq7kob34HbvQ.user.46.165.242.75.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: C99: 7.18.1.1 Exact-width integer types
Date: Wed, 26 Jan 2022 21:24:05 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86k0emc9ga.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="51875"; posting-host="3E/HvDozwKlq7kob34HbvQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:EXyRB7HSCYf6siUVs3LELHHa81A=
 by: Meredith Montgomery - Thu, 27 Jan 2022 00:24 UTC

--8<---------------cut here---------------start------------->8---
7.18.1.1 Exact-width integer types

1. The typedef name intN_t designates a signed integer type with width
N, no padding bits, and a two's complement representation. Thus,
int8_t denotes a signed integer type with a width of exactly 8 bits.
--8<---------------cut here---------------end--------------->8---

It seems C99 garantees that these nice integers types will use two's
complement. But I guess we have no such guarantee for int or char?
It's only for intN_t. Can you share your experience on this? Thank
you!

Re: C99: 7.18.1.1 Exact-width integer types

<87sftaknqn.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20229&group=comp.lang.c#20229

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: C99: 7.18.1.1 Exact-width integer types
Date: Wed, 26 Jan 2022 16:48:16 -0800
Organization: None to speak of
Lines: 43
Message-ID: <87sftaknqn.fsf@nosuchdomain.example.com>
References: <86k0emc9ga.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bf54849e5746b429a73bee48b359de83";
logging-data="3978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SUtM9tsFZps1DL0Myw8aH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:UyKq6gm2yF+FE0MTf7iV5sclQpc=
sha1:Kj2UeY8qWYmmsJpupsuvTgfiNz4=
 by: Keith Thompson - Thu, 27 Jan 2022 00:48 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> --8<---------------cut here---------------start------------->8---
> 7.18.1.1 Exact-width integer types
>
> 1. The typedef name intN_t designates a signed integer type with width
> N, no padding bits, and a two's complement representation. Thus,
> int8_t denotes a signed integer type with a width of exactly 8 bits.
> --8<---------------cut here---------------end--------------->8---
>
> It seems C99 garantees that these nice integers types will use two's
> complement. But I guess we have no such guarantee for int or char?
> It's only for intN_t. Can you share your experience on this? Thank
> you!

The intN_t types are almost certainly, for a given implementation,
defined as typedefs for one of the predefined signed integer types
(signed char, short, int, long, long long). In almost all existing
implementations, all those types use a 2's-complement representation
with no padding bits. (The few implementations for non-2's-complement
systems, as far as I know, don't even support C99 and are not likely to
in the future.)

An implementation that uses 1s'-complement or that has padding bits
simply wouldn't define the intN_t types (unless it's able to emulate
the required features).

The predefined types are mandatory, so the standard has to be a bit
flexible about representation to avoid making implementations for exotic
systems impractical. The intN_t and uintN_t types are optional, and are
defined only if the implementation can support them.

The [u]int_leastN_t and [u]int_fastN_t types do not require
2's-complement, and are mandatory for all conforming implementations for
N = 8, 16, 32, 64.

The next edition of the C standard is likely to mandate 2's-complement
for signed integer types. Padding bits are still a theoretical issue,
as are sizes other than the usual 8, 16, 32, 64.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: C99: 7.18.1.1 Exact-width integer types

<87o83ykn24.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20230&group=comp.lang.c#20230

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: C99: 7.18.1.1 Exact-width integer types
Date: Wed, 26 Jan 2022 17:02:59 -0800
Organization: None to speak of
Lines: 19
Message-ID: <87o83ykn24.fsf@nosuchdomain.example.com>
References: <86k0emc9ga.fsf@levado.to>
<87sftaknqn.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bf54849e5746b429a73bee48b359de83";
logging-data="3978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Brqb2rPA0BEc4yVcVVQCx"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:SCbO7QITgceNX2Nte+ciUN/BC00=
sha1:zdGO8vodY+j2eB59e50E0aBKwzc=
 by: Keith Thompson - Thu, 27 Jan 2022 01:02 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
> The intN_t types are almost certainly, for a given implementation,
> defined as typedefs for one of the predefined signed integer types
> (signed char, short, int, long, long long).
[...]

I wrote "almost" because they could also be implemented in terms of
extended integer types. I'm not aware of any implementation that even
has extended integer types.

But for example, an implementation with 8-bit char, 16-bit short, and
64-bit int and long might define int32_t as a typedef for an extended
32-bit type.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: C99: 7.18.1.1 Exact-width integer types

<sst07o$8pe$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20231&group=comp.lang.c#20231

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: C99: 7.18.1.1 Exact-width integer types
Date: Wed, 26 Jan 2022 21:32:22 -0500
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <sst07o$8pe$1@dont-email.me>
References: <86k0emc9ga.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jan 2022 02:32:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="28fe711c904b0c3d9c90180e5f4cb6f9";
logging-data="9006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18v7nmpDONg6XSDt4YTUQOSBcgVxbqI/eU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:t90SA9tbY1clp+4EVkeDBS0IbTA=
In-Reply-To: <86k0emc9ga.fsf@levado.to>
Content-Language: en-US
 by: James Kuyper - Thu, 27 Jan 2022 02:32 UTC

On 1/26/22 19:24, Meredith Montgomery wrote:
> --8<---------------cut here---------------start------------->8---
> 7.18.1.1 Exact-width integer types
>
> 1. The typedef name intN_t designates a signed integer type with width
> N, no padding bits, and a two's complement representation. Thus,
> int8_t denotes a signed integer type with a width of exactly 8 bits.
> --8<---------------cut here---------------end--------------->8---
>
> It seems C99 garantees that these nice integers types will use two's
> complement. But I guess we have no such guarantee for int or char?
> It's only for intN_t. Can you share your experience on this? Thank
> you!

You're correct. The size-named types are likely to be typedefs for
standard types, but they're not required to be - they could be typedefs
for extended integer types. Keep in mind that the exact-sized types are
all optional. The only size-named types that are mandatory are the least
and fast versions, and only for 8, 16, 32, and 64 bits.
Since C2011, you can test for this: _Generic() checks for compatible
types, so you find _Generic() accepting 'int' as a match for 'int32_t',
you'll know that it meets those requirements too.

You can have a fully conforming implementation of C on almost any
platform, as a matter of deliberate design, and one of the key things
that makes that true are the things like this that aren't mandatory.

As a practical matter you're seldom going to run into non- two's
complement platforms, which is why C++ has made it mandatory, and why C
may be heading in the same direction.

Re: C99: 7.18.1.1 Exact-width integer types

<sstka1$ef9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20234&group=comp.lang.c#20234

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: C99: 7.18.1.1 Exact-width integer types
Date: Thu, 27 Jan 2022 09:14:56 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <sstka1$ef9$1@dont-email.me>
References: <86k0emc9ga.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jan 2022 08:14:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="92d348c2754ce3fdb2f81df24283b966";
logging-data="14825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Mj6eodMrp+6WksQFznU47SUlCAoh6LOw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:QTZE7GL75in4oIaCCWyWFDmIHCw=
In-Reply-To: <86k0emc9ga.fsf@levado.to>
Content-Language: en-GB
 by: David Brown - Thu, 27 Jan 2022 08:14 UTC

On 27/01/2022 01:24, Meredith Montgomery wrote:
> --8<---------------cut here---------------start------------->8---
> 7.18.1.1 Exact-width integer types
>
> 1. The typedef name intN_t designates a signed integer type with width
> N, no padding bits, and a two's complement representation. Thus,
> int8_t denotes a signed integer type with a width of exactly 8 bits.
> --8<---------------cut here---------------end--------------->8---
>
> It seems C99 garantees that these nice integers types will use two's
> complement. But I guess we have no such guarantee for int or char?
> It's only for intN_t. Can you share your experience on this? Thank
> you!
>

Others have given the formal details. I'd just like to point out a
couple of other details.

While you will almost guaranteed never see a machine that does not use
two's complement signed integers without padding (except for the _Bool
type, which is a little special), there /are/ current processors that
don't have 8-bit char and therefore won't have int8_t or uint8_t. These
are mostly DSP or other niche and specialised embedded processors, but
they do exist and will do so for the foreseeable future. However,
you'll know if you are writing code for such devices, and the overlap
between code for these and code for other types of processors is very
small - it is very rare for code to have to run on both.

Another point that is sometimes misunderstood is that even when an
integer type is guaranteed to be two's complement, signed integer
arithmetic overflow is /not/ defined in C. You don't get "two's
complement wrapping" on overflow, even with types that are defined as
two's complement representation.

(When the C++ committee voted to require two's complement signed integer
representation for C++20, they explicitly rejected the idea of defining
overflow behaviour. I expect the C committee to follow the same
principle for the next C standard, probably C23.)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor