HP Fortran Programmer's Reference (September 2007)

Expressions and assignment
Expressions
Chapter 4 87
Two operands joined by a binary operator can be of different numeric types or different kind
type parameters. The type of the result is:
If the type and kind type parameters of the operands are the same, the result has the
same type and kind type parameter.
If the type of the operands is the same but the kind type parameters differ, the result has
the same type and the larger kind type parameter.
If either operand is of type complex, the result is of type complex.
If either operand is of type real and the other operand is not of type complex, the result is
of type real.
Except for a value raised to an integer power, each operand that differs in type or kind type
parameter from that of the result is converted to a value with the type and kind type of the
result before the operation is performed.
Logical and integer operands can be combined with arithmetic operators. The logical operand
is treated as an integer of the same kind type parameter, and the result of the operation is of
type integer. If the operands have different kind type parameters, the shorter is considered to
be extended as a signed integer. For information about logical values, see “Logical operators”
on page 88.
The arithmetic operators behave as expected, with the following qualifications:
The division of an integer by an integer is defined to be the integer closest to the true
result that is between zero and the true result.
Exponentiation of an integer to a negative integer—i1**i2, where i2 is negative—is
interpreted as 1/(i1**(-i2)), where the division is interpreted as described for division
of one integer by another.
•Ifx1 and x2 are real and x1 is negative, then x1**x2 could be an invalid expression, as
the result could be complex. Note, however, that CMPLX(x1)**x2 is valid; the result is the
principal value.
The following are HP extensions to the Fortran 90 Standard:
The exponentiation operator may be followed by a signed entity, as in the following
example:
i ** -j
The Fortran 90 Standard does not allow adjacent operators.