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:
Operand type |
---|
long double |
double |
float |
Operand type |
---|
_Decimal128 |
_Decimal64 |
_Decimal32 |
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 |
Related information