Skip to content

FORTRAN Logical Operators

Home arrow Computational arrow FORTRAN arrow FORTRAN Logical Operators


FORTRAN Logical Operators E-mail
User Rating: / 0
PoorBest 
FORTRAN Logical Operators
Logical Operators

The logical operators are:
Logical Operators.
Logical Operators
Operator Representing
.NOT. Logical Negation
.AND. Logical Conjunction
.OR. Logical Inclusive Disjunction
.EQV. Logical Equivalence
.NEQV. Logical Nonequivalence


Form and Interpretation of Logical Expressions.
A set of formation rules is used to establish the interpretation of a logical expression that contains two or more logical operators. There is a precedence among the logical operators, which determines the order in which the operands are to be combined unless the order is changed by the use of parentheses. The precedence of the logical operators is as follows:

Form and Interpretation of Logical Expressions
Logical Expressions
Operator Representing
.NOT. Highest
.AND.  
.OR.  
.EQV. or .NEQV. Lowest


For example, in the expression
A .OR. B .AND. C

the .AND. operator has higher precedence than the .OR. operator; therefore, the interpretation of the above expression is the same as the interpretation of the expression

A .OR. (B .AND. C)


Value of Logical Factors, Terms, Disjuncts, and Expressions.
The value of a logical factor involving .NOT. Is shown below:
Logical factor involving .NOT.
Logic 1 .NOT. (Logic 1)
TRUE FALSE
FALSE TRUE


The value of a logical term involving .AND. is shown below:

Logical factor involving .AND.
Logic 1 Logic 2 (Logic 1) .AND. (Logic 2)
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE


The value of a logical term involving .OR. is shown below:

Logical factor involving .OR.
Logic 1 Logic 2 (Logic 1) .OR. (Logic 2)
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE


The value of a logical term involving .EQV. is shown below:

Logical factor involving .EQV.
Logic 1 Logic 2 (Logic 1) .EQV. (Logic 2)
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE TRUE


The value of a logical term involving .NEQV. is shown below:

Logical factor involving .NEQV.
Logic 1 Logic 2 (Logic 1) .NEQV. (Logic 2)
TRUE TRUE FALSE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE