NOT(3) - [BIT:LOGICAL] Logical negation; flips all bits in an integer
result = not(i)
elemental integer(kind=KIND) function not(i)
integer(kind=KIND), intent(in) :: i
o I may be an integer of any valid kind o The returned integer is of the same kind as the argument I.
NOT(3) returns the bitwise Boolean inverse of I. This is also known as the "Bitwise complement" or "Logical negation" of the value.
If an input bit is a one, that position is a zero on output. Conversely any input bit that is zero is a one on output.
o I : The value to flip the bits of.
The result has the value obtained by complementing I bit-by-bit according to the following truth table:
> I | NOT(I) > ----#---------- > 1 | 0 > 0 | 1That is, every input bit is flipped.
Sample program
program demo_not implicit none integer :: i ! basics i=-13741 print *,the input value,i,represented in bits is write(*,(1x,b32.32,1x,i0)) i, i i=not(i) print *,on output it is,i write(*,(1x,b32.32,1x,i0)) i, i print *, " on a twos complement machine flip the bits and add 1" print *, " to get the value with the sign changed, for example." print *, 1234, not(1234)+1 print *, -1234, not(-1234)+1 print *, " of course x=-x works just fine and more generally." end program demo_notResults:
> the input value -13741 represented in bits is > 11111111111111111100101001010011 -13741 > on output it is 13740 > 00000000000000000011010110101100 13740 > on a twos complement machine flip the bits and add 1 > to get the value with the sign changed, for example. > 1234 -1234 > -1234 1234 > of course x=-x works just fine and more generally.
Fortran 95
IAND(3), IOR(3), IEOR(3), IBITS(3), IBSET(3),
IBCLR(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | not (3fortran) | November 02, 2024 |