FORTRAN Reference Manual

Expressions
FORTRAN Reference Manual528615-001
3-9
Logical Expressions
The following examples are invalid:
DOUBLE PRECISION y
COMPLEX x, z
LOGICAL a, b
READ (*,*) x, y, z
a = x .LE. y <-- Cannot compare complex and
double precision values
b = z .GT. x <-- Relational operator is not .EQ.
or .NE. and one of the operands is a complex value.
Logical Expressions
A logical expression designates a logical computation whose result is either true or
false. The syntax of a logical expression is:
logic-exp
is a logical expression enclosed in parentheses, a relational expression, a logical
constant, a logical symbolic constant, a logical variable, a logical array element
reference, or a logical function reference.
logic-op
is one of:
AND.
.OR.
.EQV.
.NEQV.
Table 3-5 describes the meaning and use of the logical operators.
[.NOT.] logic-exp [ logic-op [.NOT.] logic-exp ]...
Table 3-5. Logical Operators
Operator Operation Example Meaning
.NOT. Negation .NOT. x Complement X
.AND. Conjunction x .AND. y Boolean product of X and Y
.OR. Inclusive disjunction x .OR. y Boolean sum of X and Y
.EQV. Equivalence x .EQV. y X and Y are both true or both false
.NEQV. Nonequivalence x .NEQV. y X is true and Y is false, or X is false and
Y is true