Compaq Fortran for Tru64 UNIX Alpha Systems V5.4
bit (3f)
the and, or, xor, not, rshift, and lshift bitwise functions
Syntax
(intrinsic) integer*4 and
integer*4 dt, word1, word2
external and
dt = and ( word1, word2 )
(intrinsic) integer*4 or
integer*4 dt, word1, word2
external or
dt = or ( word1, word2 )
(intrinsic) integer*4 xor
integer*4 dt, word1, word2
external xor
dt = xor ( word1, word2 )
(intrinsic) integer*4 not
integer*4 dt, word
external not
dt = not ( word )
(intrinsic) integer*4 rshift
integer*4 dt, word, nbits
external rshift
dt = rshift ( word, nbits )
(intrinsic) integer*4 lshift
integer*4 dt, word, nbits
external lshift
dt = lshift ( word, nbits )
Description
These bitwise functions are built into the compiler and return the data
type of their arguments. Their arguments must be integer or logical
values.
The logical functions return the following:
and Returns the bitwise AND of two operands
or Returns the bitwise OR of two operands
xor Returns the bitwise exclusive OR of two operands
not Returns the bitwise complement of its operand
The lshift function shifts word left by nbits bits. The rshift function
shifts word right by nbits bits. No test is made for a reasonable value of
nbits.
These functions may be used to create a variety of general routines, as in
the following statement function definitions:
integer bitset, bitclr, getbit, word, bitnum
bitset( word, bitnum ) = or( word,lshift( 1,bitnum ) )
bitclr( word, bitnum ) = and( word,not( lshift( 1,bitnum ) ) )
getbit( word, bitnum ) = and( rshift( word,bitnum ),1 )
See Also
DEC Fortran Language Reference Manual