8.16 AND — Bitwise logical AND

Description:

Bitwise logical AND.

This intrinsic routine is provided for backwards compatibility with GNU Fortran 77. For integer arguments, programmers should consider the use of the IAND — Bitwise logical and intrinsic defined by the Fortran standard.

Standard:

GNU extension

Class:

Function

Syntax:

RESULT = AND(I, J)

Arguments:
IThe type shall be either a scalar INTEGER type or a scalar LOGICAL type or a boz-literal-constant.
JThe type shall be the same as the type of I or a boz-literal-constant. I and J shall not both be boz-literal-constants. If either I or J is a boz-literal-constant, then the other argument must be a scalar INTEGER.
Return value:

The return type is either a scalar INTEGER or a scalar LOGICAL. If the kind type parameters differ, then the smaller kind type is implicitly converted to larger kind, and the return has the larger kind. A boz-literal-constant is converted to an INTEGER with the kind type parameter of the other argument as-if a call to INT — Convert to integer type occurred.

Example:
PROGRAM test_and
  LOGICAL :: T = .TRUE., F = .FALSE.
  INTEGER :: a, b
  DATA a / Z'F' /, b / Z'3' /

  WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
  WRITE (*,*) AND(a, b)
END PROGRAM
See also:

Fortran 95 elemental function:
IAND — Bitwise logical and