Promotion and Demotion
Data types are ordered according to the largest magnitude they can represent.
For example,
int32_t
is obviously "larger" than
int16_t
.
But this also means that unsigned integers are always larger than signed integers of the same size.
Promotion occurs when a value is copied to a larger data type.
Demotion occurs when a value is copied to a smaller data type.
In either case, information may be lost if the value cannot be represented
in the new data type - either because the number of bits is insufficient, or
because a negative value is copied to an unsigned integer.
(Click anywhere to remove this message.)