IAND(3) - [BIT:LOGICAL] Bitwise logical AND
result = iand(i, j)
elemental integer(kind=KIND) function iand(i,j)integer(kind=KIND),intent(in) :: i integer(kind=KIND),intent(in) :: j
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.
IAND(3) returns the bitwise logical AND of two values.
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.
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
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.
Sample program:
program demo_iand implicit none integer :: a, b data a / zf /, b / z3 / write (*,*) a=,a, b=,b,iand(a,b)=,iand(a, b) write (*,(b32.32)) a,b,iand(a,b) end program demo_iandResults:
> a= 15 b= 3 iand(a,b)= 3 > 00000000000000000000000000001111 > 00000000000000000000000000000011 > 00000000000000000000000000000011
Fortran 2023
BTEST(3), IBCLR(3), IBITS(3), IBSET(3), IEOR(3), IOR(3), MVBITS(3), NOT(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | iand (3fortran) | November 02, 2024 |