Integral and floating-point promotions
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
- int
- unsigned int
- long int
- unsigned long int
- long long int
- unsigned long long int
Integral promotion rules for bit field
- 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 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 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.
- 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 -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 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.
- 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.