Manual Reference Pages  - not (3fortran)

NAME

NOT(3) - [BIT:LOGICAL] Logical negation; flips all bits in an integer

SYNOPSIS

result = not(i)

elemental integer(kind=KIND) function not(i)

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

CHARACTERISTICS

o I may be an integer of any valid kind
o The returned integer is of the same kind as the argument I.

DESCRIPTION

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.

OPTIONS

o I : The value to flip the bits of.

RESULT

The result has the value obtained by complementing I bit-by-bit according to the following truth table:

       >    I   |  NOT(I)
       >    ----#----------
       >    1   |   0
       >    0   |   1

That is, every input bit is flipped.

EXAMPLES

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 two’s 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_not

Results:

        the input value      -13741 represented in bits is
        11111111111111111100101001010011 -13741
        on output it is       13740
        00000000000000000011010110101100 13740
         on a two’s 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.

STANDARD

Fortran 95

SEE ALSO

IAND(3), IOR(3), IEOR(3), IBITS(3), IBSET(3),

IBCLR(3)

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


Nemo Release 3.1 not (3fortran) April 28, 2024
Generated by manServer 1.08 from b998ec77-1295-4787-8c6d-15c3d47ae7e4 using man macros.