Manual Reference Pages  - iand (3fortran)

NAME

IAND(3) - [BIT:LOGICAL] Bitwise logical AND

SYNOPSIS

result = iand(i, j)

         elemental integer(kind=KIND) function iand(i,j)

integer(kind=KIND),intent(in) :: i integer(kind=KIND),intent(in) :: j

CHARACTERISTICS

o I, J and the result shall have the same integer type and kind, with the exception that one of I or J may be a BOZ constant.

DESCRIPTION

IAND(3) returns the bitwise logical AND of two values.

OPTIONS

o I : one of the pair of values to compare the bits of
o J : one of the pair of values to compare the bits of
If either I or J is a BOZ-literal-constant, it is first converted as if by the intrinsic function INT(3) to type integer with the kind type parameter of the other.

RESULT

The result has the value obtained by combining I and I bit-by-bit according to the following table:

        I  |  J  |  IAND (I, J)
----------------------------
1 | 1 | 1
1 | 0 | 0
0 | 1 | 0
0 | 0 | 0

So if both the bit in I and J are on the resulting bit is on (a one); else the resulting bit is off (a zero).

This is commonly called the "bitwise logical AND" of the two values.

EXAMPLES

Sample program:

    program demo_iand
    implicit none
    integer :: a, b
     data a / z’f’ /, b / z’3’ /
     write (*,*) ’a=’,a,’ b=’,b,’iand(a,b)=’,iand(a, b)
     write (*,’(b32.32)’) a,b,iand(a,b)
    end program demo_iand

Results:

        a= 15  b= 3 iand(a,b)= 3
00000000000000000000000000001111 00000000000000000000000000000011 00000000000000000000000000000011

STANDARD

Fortran 95

SEE ALSO

BTEST(3), IBCLR(3), IBITS(3), IBSET(3), IEOR(3), IOR(3), MVBITS(3), NOT(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 iand (3fortran) April 28, 2024
Generated by manServer 1.08 from b2f4be57-7216-475d-9b47-75c69ed451ca using man macros.