Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #71120
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: uint32_t is not the same as long unsigned int ? |
| Date | 2020-01-04 14:48 -0800 |
| Organization | None to speak of |
| Message-ID | <8736cuon1x.fsf@nosuchdomain.example.com> (permalink) |
| References | <qup223$eje$1@dont-email.me> <qup3ng$krp$1@dont-email.me> <87k167odry.fsf@nosuchdomain.example.com> <quq8k3$4he$1@dont-email.me> |
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 1/4/20 2:56 AM, Keith Thompson wrote:
>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>> [...]
>>> The actual requirements are in terms of the required range of values
>>> that each standard integer type must be able to represent, and are
>>> incorporated by reference from the C standard. I've converted those
>>> ranges into bit counts to better match your question.
>>
>> A quibble: the required ranges of values for the standard integer types
>> are copied from the C standard, but are not incorporated by reference.
>
> In my copy of n4567.pdf, 18.3.3 says:
>
> "1 Table 31 describes the header <climits>.
> 2 The contents are the same as the Standard C library header <limits.h>"
>
> 18.3.3p2 is precisely the kind of wording that "incorporated by
> reference" means to me. What does it mean to you?
>
> The "description" in table 31 is the only place that the C++ standard
> that all of the *_MIN and *_MAX macros are referred to. The meanings of
> those macros and the maximum and minimum (respectively) permitted values
> for those macros which are only given in the C standard. If you read
> only the C++ standard, you might not even realize that it imposes any
> limits on the sizes of integer types, however indirectly.
You're right. N4567 3.9.1 [basic.fundamental] paragraph 3 says:
The signed and unsigned integer types shall satisfy the constraints
given in the C standard, section 5.2.4.2.1.
My earlier post was based on N4842, which is a working draft for C++20
(and happens to be the document that I had open at the time). In that
draft, 6.8.1 [basic.fundamental] paragraph 3 includes a table showing
the minimum widths of the 5 signed integer types:
Type Minimum width N
signed char 8
short 16
int 16
long 32
long long 64
The widths are sufficient to specify the ranges, since unlike the
current edition of the C++ standard, N4842 mandates 2's-complement
for signed integers, including the extra negative value:
The range of representable values for a signed integer type is
ā2**(Nā1) to 2**(Nā1) ā 1 (inclusive), where N is called the *width*
of the type.
...
An unsigned integer type has the same object representation,
value representation, and alignment requirements (6.7.6) as
the corresponding signed integer type. For each value x of a
signed integer type, the value of the corresponding unsigned
integer type congruent to x modulo 2**N has the same value of
corresponding bits in its value representation.
(expressions tweaked to avoid superscripts).
Of course N4842 is not a standard, and I should have checked the current
edition.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
[Note updated email address]
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
uint32_t is not the same as long unsigned int ? wolfgang bauer <schutz@gmx.de> - 2020-01-04 04:50 +0100
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-03 23:18 -0500
Re: uint32_t is not the same as long unsigned int ? wolfgang bauer <schutz@gmx.de> - 2020-01-04 05:36 +0100
Re: uint32_t is not the same as long unsigned int ? Robert Wessel <robertwessel2@yahoo.com> - 2020-01-04 00:19 -0600
Re: uint32_t is not the same as long unsigned int ? Barry Schwarz <schwarzb@delq.com> - 2020-01-03 22:29 -0800
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-03 23:56 -0800
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 09:48 -0500
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 14:48 -0800
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 21:39 -0500
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 19:43 -0800
Re: uint32_t is not the same as long unsigned int ? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-01-05 06:09 +0100
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-05 20:50 -0500
Re: uint32_t is not the same as long unsigned int ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-04 08:37 +0000
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 02:16 -0800
Thank you. (was:Re: uint32_t is not the same as long unsigned int ?) wolfgang bauer <schutz@gmx.de> - 2020-01-04 15:15 +0100
csiph-web