分类: LINUX
2011-07-14 10:18:33
The conversions depend on the specific operator and the type of the operand or operands. However, many operators perform similar conversions on operands of integer and floating-point types. These standard conversions are known as the arithmetic conversions because they apply to the types of values ordinarily used in arithmetic.
Arithmetic conversions are used for matching operands of arithmetic operators.
Arithmetic conversion proceeds in the following order:
Operand Type | Conversion |
---|---|
One operand has long double type | The other operand is converted to long double. |
One operand has double type | The other operand is converted to double. |
One operand has float type | The other operand is converted to float. |
One operand has unsigned long long int type | The other operand is converted to unsigned long long int |
One operand has long long type. | The other operand is converted to long long. |
One operand has unsigned long int type | The other operand is converted to unsigned long int. |
One operand has unsigned int type and the other operand has long int type and the value of the unsigned int can be represented in a long int | The operand with unsigned int type is converted to long int. |
One operand has unsigned int type and the other operand has long int type and the value of the unsigned int cannot be represented in a long int | Both operands are converted to unsigned long int. |
One operand has long int type | The other operand is converted to long int. |
One operand has unsigned int type | The other operand is converted to unsigned int. |
Both operands have int type | The result is type int. |