HP C/iX Reference Manual (31506-90011)
Chapter 4 51
Type Conversions
Usual Arithmetic Conversions
Usual Arithmetic Conversions
In many expressions involving two operands, the operands are converted according to the
following rules, known as the usual arithmetic conversions. The common type resulting
from the application of these rules is also the type of the result. These rules are applied in
the sequence listed below.
1. If either operand is long double, the other operand is converted to long double.
2. If either operand is double, the other operand is converted to double.
3. If either operand is float, the other operand is converted to float.
4. Integral promotions are performed on both operands, and then the rules listed below
are followed.
a. If either operand is unsigned long int, the other operand is converted to unsigned
long int.
b. If one operand is long int and the other is unsigned int, both operands are converted
to unsigned long int.
c. If either operand is long int, the other operand is converted to long int.
d. If either operand is unsigned int, the other operand is converted to unsigned int.
e. Otherwise, both operands have type int.
NOTE
In non-ANSI mode, the rules are slightly different.
Rule 1: Does not apply, because long double is not supported in non-ANSI mode.
Rule 3: Does not apply, because in non-ANSI mode, whenever a float appears in an
expression, it is immediately converted to a double.
Rule 4: The integral promotions are performed according to the unsigned
preserving rules when compiling in non-ANSI mode.