Does [stdint.h] guarantee two's complement form?

  • Thread starter Alf P. Steinbach /Usenet
  • Start date
A

Alf P. Steinbach /Usenet

In the C99 standard draft N869, §7.18.2.1,

minimum values of exact-width signed integer types
INTn_MIN exactly either 1-2^(n-1) or -2^(n-1)

where the first possibility is sign-and-magnitude and one's complement, and the
second is for two's complement.

However,

http://en.wikipedia.org/wiki/Stdint.h#Exact-width_integer_types

claims that

intN_t must be encoded as a two's complement signed integer and uintN_t as an
unsigned integer

and later on goes into a discussion of how this guarantee can be troublesome.

To some degree that claim is corroborated by

http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html

which states that, for the [stdint.h] that it defines,

The typedef name int N _t designates a signed integer type with width N, no
padding bits, and a two's-complement representation.

but this may be just an additional Posix guarantee (although it's not marked as
such).

Which is correct wrt. to the C99 and C++0x [stdint.h]?


Cheers,

- Alf
 
I

Ian Collins

In the C99 standard draft N869, §7.18.2.1,

minimum values of exact-width signed integer types
INTn_MIN exactly either 1-2^(n-1) or -2^(n-1)

where the first possibility is sign-and-magnitude and one's complement,
and the second is for two's complement.

However,

http://en.wikipedia.org/wiki/Stdint.h#Exact-width_integer_types

claims that

intN_t must be encoded as a two's complement signed integer and uintN_t
as an
unsigned integer

and later on goes into a discussion of how this guarantee can be
troublesome.

To some degree that claim is corroborated by

http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html

which states that, for the [stdint.h] that it defines,

The typedef name int N _t designates a signed integer type with width N, no
padding bits, and a two's-complement representation.

but this may be just an additional Posix guarantee (although it's not
marked as such).

Which is correct wrt. to the C99 and C++0x [stdint.h]?

From C99:

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.
 
A

Alf P. Steinbach /Usenet

* Ian Collins, on 20.09.2010 03:24:
In the C99 standard draft N869, §7.18.2.1,

minimum values of exact-width signed integer types
INTn_MIN exactly either 1-2^(n-1) or -2^(n-1)

where the first possibility is sign-and-magnitude and one's complement,
and the second is for two's complement.

However,

http://en.wikipedia.org/wiki/Stdint.h#Exact-width_integer_types

claims that

intN_t must be encoded as a two's complement signed integer and uintN_t
as an
unsigned integer

and later on goes into a discussion of how this guarantee can be
troublesome.

To some degree that claim is corroborated by

http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html

which states that, for the [stdint.h] that it defines,

The typedef name int N _t designates a signed integer type with width N, no
padding bits, and a two's-complement representation.

but this may be just an additional Posix guarantee (although it's not
marked as such).

Which is correct wrt. to the C99 and C++0x [stdint.h]?

From C99:

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.

Thanks. The N869 draft leaves out the bit after the first comma.

Cheers,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top