FORTRAN Reference Manual

Expressions
FORTRAN Reference Manual528615-001
3-10
Logical Expressions
If a logical expression contains two or more logical operators, FORTRAN uses the
following hierarchy to determine the order in which the operators are evaluated:
.NOT. <-- Highest
.AND.
.OR.
.EQV. or .NEQV. <-- Lowest
The following expressions are equivalent:
x .OR. y .AND. z
x .OR. (y .AND. z)
You can use parentheses to override the normal order of precedence, as in the
following example:
(x .OR. y) .AND. z
If an expression contains two or more adjacent .AND. operators, .OR. operators, .EQV.
operators, or .NEQV. operators, FORTRAN evaluates the expression from left to right.
Table 3-6 shows the results of combining two logical elements with the logical
operators.
Table 3-6. Evaluation of Logical Expressions (page 1 of 2)
Operator Operand Operand Result
.NOT. .TRUE. .FALSE.
..FALSE. ..TRUE.
.AND. .TRUE. .TRUE. .TRUE.
.TRUE. .FALSE. .FALSE.
.FALSE. .TRUE. .FALSE.
.FALSE. .FALSE. .FALSE.
.OR. .TRUE. .TRUE. .TRUE.
.TRUE. .FALSE. .TRUE.
.FALSE. .TRUE. .TRUE.
.FALSE. .FALSE. .FALSE.
.EQV. .TRUE. .TRUE. .TRUE.
.TRUE. .FALSE. .FALSE.
.FALSE. .TRUE. .FALSE.
.FALSE. .FALSE. .TRUE.