views:

57

answers:

2

6.3.1.1 States

The rank of a signed integer type shall be greater than the rank of any signed integer type with less precision.

The rank of long long int shall be greater than the rank of long int, which shall be greater than the rank of int, which shall be greater than the rank of short int, which shall be greater than the rank of signed char.


So, could this not be the case

signed   char has 32 bits (1 padding, 1 sign, 30 precision)
unsigned char has 32 bits (0 padding, 0 sign, 32 precision)
signed   int  has 32 bits (1 padding, 1 sign, 30 precision)
unsigned int  has 32 bits (2 padding, 0 sign, 30 precision)
+2  A: 

Just found my own answer. This is not allowed, according to 6.2.5 (8)

For any two integer types with the same signedness and different integer conversion rank (see 6.3.1.1), the range of values of the type with smaller integer conversion rank is a subrange of the values of the other type.

Elite Mx
A: 

You assumptions about char variables are wrong. In limits.h, CHAR_BIT is 8. You have 32.

In the standard '5.2.4.2.1 Sizes of integer types ' defines CHAR_BIT as 8.

jim mcnamara
Did you not read the opening paragraph, which near the bottom states "Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown ...".
Elite Mx