Integral and floating-point promotions

When different arithmetic types are used as operands in certain types of expressions, standard conversions known as usual arithmetic conversions are applied. These conversions are applied according to the rank of the arithmetic type: the operand with a type of lower rank is converted to the type of the operand with a higher rank. This is known as integral or floating point promotion.

For example, when the values of two different integral types are added together, both values are first converted to the same type: when a short int value and an int value are added together, the short int value is converted to the int type. Expressions and operators provides a list of the operators and expressions that participate in the usual arithmetic conversions.

The ranking of arithmetic types, listed from highest to lowest, is as follows:

Table 13. Conversion rankings for floating-point types
Operand type
long double
double
float
Table 14. Conversion rankings for decimal floating-point types
Operand type
IBM extension _Decimal128
IBM extension _Decimal64
IBM extension _Decimal32
Table 15. Conversion rankings for integer types
Operand type
unsigned long long or unsigned long long int
long long or long long int
unsigned long int
long int1
unsigned int1
int and enumerated types
short int
char, signed char and unsigned char
Boolean
Notes:
  1. If one operand has unsigned int type and the other operand has long int type but the value of the unsigned int cannot be represented in a long int, both operands are converted to unsigned long int.

Related information



[ Top of Page | Previous Page | Next Page | Contents | Index ]