M
Michael Mair
Lawrence said:That is true for unsigned char, but for other unsigned types padding bits
are allowed. See e.g. C99 6.2.6.2p1
The requirement on range is that C99 6.2.5p9:
"The range of nonnegative values of a signed integer type is a subrange of
the corresponding unsigned integer type, and the representation of the
same value in each type is the same."
So an implementation of unsigned types which is the same as the
corresponding signed type except that the sign bit is a padding bit is
valid, except for unsigned char.
There are minimum range limits e.g. UINT_MAX must be at least 65535. So if
unsigned int was 16 bits wide it would have to use all bits as value bits.
But a 32 bit wide one does not.
Thank you for the information!
Cheers
Michael