Next: Relational Operators
Up: Using MathMaps
Previous: Arithmetic Operators

## Logical Operators

Logical values are represented using zero to indicate .FALSE. And non-zero to indicate .TRUE.. In addition, the bad value is taken to mean "unknown". The values returned by logical operators may therefore be 0, 1 or bad. Where appropriate, "tri-state" logic is implemented. For example, A.OR.B may evaluate to 1 if A is non-zero, even if B has the bad value. This is because the result of the operation would not be affected by the value of B, so long as A is non-zero.

The following logical operators are available:

• X1 .AND. X2: Logical AND between X1 and X2, returning 1 if both X1 and X2 are non-zero, and 0 otherwise. This operator implements tri-state logic. (The synonym "&SPMamp;" is also provided for compatibility with C.)

• X1 .OR. X2: Logical OR between X1 and X2, returning 1 if either X1 or X2 are non-zero, and 0 otherwise. This operator implements tri-state logic. (The synonym " " is also provided for compatibility with C.)

• X1 .NEQV. X2: Logical exclusive OR (XOR) between X1 and X2, returning 1 if exactly one of X1 and X2 is non-zero, and 0 otherwise. Tri-state logic is not used with this operator. (The synonym ".XOR." is also provided, although this is not standard Fortran. In addition, the C-like synonym " " may be used, although this is also not standard.)

• X1 .EQV. X2: Tests whether the logical states of X1 and X2 (i.e. .TRUE./.FALSE.) are equal. It is the negative of the exclusive OR (XOR) function. Tri-state logic is not used with this operator.

• .NOT. X: Logical unary NOT operation, returning 1 if X is zero, and 0 otherwise. (The synonym "!" is also provided for compatibility with C.)

Next: Relational Operators
Up: Using MathMaps
Previous: Arithmetic Operators

KAPPA --- Kernel Application Package