The integral and floating-point promotions are
used automatically as part of the usual arithmetic conversions and
default argument promotions. The integral and floating-point promotions
do not change either the sign or the magnitude of the value. For more
information about the usual arithmetic conversions, see Usual arithmetic conversions.
Integral promotion rules for wchar_t
If
a value is of the wchar_t type, the type of the value can be converted
to the first of the following types that can represent all the values
of the underlying type of wchar_t:
- int
- unsigned int
- long int
- unsigned long int
- long long int
- unsigned long long int
If none of the types in the list can represent all the values
of the underlying type of wchar_t, the wchar_t type is converted to
the underlying type of wchar_t.
Integral promotion rules for bit field
The
rules apply to the following conditions:
- The -qupconv option is in effect.
- The type of an integral bit field is unsigned.
- The type of the integral bit field is smaller than the int type.
If all these conditions are satisfied, one of the following rules
applies to the promotion of the integral bit field:
- If the unsigned int type can represent all the
values of the integral bit field, the bit field is converted to unsigned
int.
- Otherwise, no integral promotion applies to the bit field.
If any of these conditions is not satisfied, one of the following
rules applies to the promotion of the integral bit field:
- If the int type can represent all the values
of the integral bit field, the bit field is converted to int.
- Otherwise, if the unsigned int type can represent
all the values, the bit field is converted to unsigned int.
- Otherwise, no integral promotion applies to the bit field.
One of the
following rules applies to an integral bit field promotion:
- If the int type can represent all the values
of an integral bit field, the bit field is converted to int.
- Otherwise, if the unsigned int type can represent
all the values, the bit field is converted to unsigned int.
- Otherwise, no integral promotion applies to the bit field.
Integral promotion rules for Boolean
If
the -qupconv option is in effect, a Boolean value
is converted to the unsigned int type with its value
unchanged. Otherwise, if the -qnoupconv option
is in effect, a Boolean value is converted to the int type
with its value unchanged.
If a Boolean value is false,
it is converted to an int with a value of 0. If a
Boolean value is true, it is converted to an int with
a value of 1.
Integral promotion rules for other types
The
rules apply to the following conditions:
- The -qupconv option is in effect.
- The type of an integer type other than bit field and Boolean is unsigned.
- The type of the integer type is smaller than the int type.
If all these conditions are satisfied, the integer type is converted
to the
unsigned int type.
If any of these conditions
is not satisfied, one of the following rules applies to the promotion
of the integer type:
- If the integer type can be represented by the int type
and its rank is lower than the rank of int, the integer
type is converted to the int type.
- Otherwise, the integer type is converted to the unsigned
int type.
One of the
following rules applies to the promotion of an integer type other
than wchar_t, bit field, and Boolean:
- If the integer type can be represented by the int type
and its rank is lower than the rank of int, the integer
type is converted to the int type.
- Otherwise, the integer type is converted to the unsigned
int type.
floating-point promotion rules
The float type
can be converted to the double type. The float value
is not changed after the promotion.