Usual Arithmetic Conversions [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Reference Manual
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.
MPE/iX 5.0 Documentation