Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #164667
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: C99: 7.18.1.1 Exact-width integer types |
| Date | 2022-01-26 21:32 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <sst07o$8pe$1@dont-email.me> (permalink) |
| References | <86k0emc9ga.fsf@levado.to> |
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.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C99: 7.18.1.1 Exact-width integer types Meredith Montgomery <mmontgomery@levado.to> - 2022-01-26 21:24 -0300
Re: C99: 7.18.1.1 Exact-width integer types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-01-26 16:48 -0800
Re: C99: 7.18.1.1 Exact-width integer types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-01-26 17:02 -0800
Re: C99: 7.18.1.1 Exact-width integer types James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-01-26 21:32 -0500
Re: C99: 7.18.1.1 Exact-width integer types David Brown <david.brown@hesbynett.no> - 2022-01-27 09:14 +0100
csiph-web