Value of a logical expression

Given that x1 and x2 represent logical values, use the following tables to determine the values of logical expressions:
x1 .NOT. x1
True False
False True
x1 x2 .AND. .OR. .XOR. .EQV. .NEQV.
False False False False False True False
False True False True True False True
True False False True True False True
True True True True False True False
Sometimes a logical expression does not need to be completely evaluated to determine its value. Consider the following logical expression (assume that LFCT is a function of type logical):
A .LT. B .OR. LFCT(Z)

If A is less than B, the evaluation of the function reference is not required to determine that this expression is true.

XL Fortran evaluates a logical expression to a LOGICAL(n) or INTEGER(n) result, where n is the kind type parameter. The value of n depends on the kind parameter of each operand.

By default, for the unary logical operator .NOT., n will be the same as the kind type parameter of the operand. For example, if the operand is LOGICAL(2), the result will also be LOGICAL(2).

The following table shows the resultant type for unary operations:

OPERAND RESULT of Unary Operation
BYTE 1  INTEGER(1) 1 
LOGICAL(1) LOGICAL(1)
LOGICAL(2) LOGICAL(2)
LOGICAL(4) LOGICAL(4)
LOGICAL(8) LOGICAL(8)
Typeless 1  Default integer 1 
Note:
  1. IBM extension

If the operands are of the same length, n will be that length.

IBM extension begins For binary logical operations with operands that have different kind type parameters, the kind type parameter of the expression is the same as the larger length of the two operands. For example, if one operand is LOGICAL(4) and the other LOGICAL(2), the result will be LOGICAL(4). IBM extension ends

The following table shows the resultant type for binary operations:

Table 1. Result Types for binary logical expressions
  second operand

first
operand

*BYTE LOGICAL(1) LOGICAL(2) LOGICAL(4) LOGICAL(8) *Typeless
*BYTE *INTEGER(1) *LOGICAL(1) *LOGICAL(2) *LOGICAL(4) *LOGICAL(8) *INTEGER(1)
LOGICAL(1) LOGICAL(1) LOGICAL(1) LOGICAL(2) LOGICAL(4) LOGICAL(8) LOGICAL(1)
LOGICAL(2) LOGICAL(2) LOGICAL(2) LOGICAL(2) LOGICAL(4) LOGICAL(8) LOGICAL(2)
LOGICAL(4) LOGICAL(4) LOGICAL(4) LOGICAL(4) LOGICAL(4) LOGICAL(8) LOGICAL(4)
LOGICAL(8) LOGICAL(8) LOGICAL(8) LOGICAL(8) LOGICAL(8) LOGICAL(8) LOGICAL(8)
*Typeless *INTEGER(1) *LOGICAL(1) *LOGICAL(2) *LOGICAL(4) *LOGICAL(8) *Default Integer
Note: * Resultant types for binary logical expressions in XL Fortran

If the expression result is to be treated as a default integer but the value cannot be represented within the value range for a default integer, the constant is promoted to a representable kind.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us