In another ANSI C manual I found the following rules, which are
different from the previous ones.
Which one are good then??
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. These rules are a strict extension of
the ANSI "Usual Arithmetic Conversions" rule (Section 3.2.1.5). This
extension ensures that integral expressions will involve long long only
if one of the operands is of type long long. For ANSI conforming
compilation, the integral promotion rule is as defined in Section
3.2.1.1 of the Standard. For non-ANSI compilation, the unsigned
preserving promotion rule is used.
1.
If either operand is unsigned long long, the other operand
is converted to unsigned long long,
2.
otherwise, if one operand is long long, the other operand
is converted to long long,
3.
otherwise, if either operand is unsigned long int, the
other operand is converted to unsigned long int,
4.
otherwise, if one operand is long int, and the other is
unsigned
int, and long int can represent all the values of an
unsigned
int, then the unsigned int is converted to a long int. (If
one operand is long int, and the other is unsigned int, and long int
can NOT represent all the values of an unsigned int, then both operands
are converted to unsigned long int.)
5.
If either operand is long int, the other operand is
converted to long int.
6.
If either operand is unsigned int, the other operand is
converted to unsigned int.
7.
Otherwise, both operands have type int.
Regards
Thad Smith wrote:
Are this rules good or maybe can you suggest anything better?
They are correct and useful, assuming you understand what is meant by
integer rank.
--
Thad