IOR(3) - [BIT:LOGICAL] Bitwise logical inclusive OR
result = ior(i, j)
elemental integer(kind=KIND) function ior(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.
IOR(3) returns the bit-wise Boolean inclusive-or of I and J.
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 J bit-by-bit according to the following table:
I J IOR (I, J) 1 1 1 1 0 1 0 1 1 0 0 0Where if the bit is set in either input value, it is set in the result. Otherwise the result bit is zero.
This is commonly called the "bitwise logical inclusive OR" of the two values.
Sample program:
program demo_ior implicit none integer :: i, j, k i=53 ! i=00110101 binary (lowest order byte) j=45 ! j=00101101 binary (lowest order byte) k=ior(i,j) ! k=00111101 binary (lowest order byte), k=61 decimal write(*,(i8,1x,b8.8))i,i,j,j,k,k end program demo_iorResults:
> 53 00110101 > 45 00101101 > 61 00111101
Fortran 95
BTEST(3), IAND(3), IBCLR(3), IBITS(3), IBSET(3), IEOR(3), MVBITS(3), NOT(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | ior (3fortran) | November 02, 2024 |