 Syntax:

boole
op integer1 integer2
resultinteger
 Arguments and Values:

Op  a bitwise logical operation specifier.
integer1  an integer.
integer2  an integer.
resultinteger  an integer.
 Description:

boole performs bitwise logical operations on
integer1 and integer2, which are treated as if
they were binary and in two's complement representation.
The operation to be performed and the return value are determined by
op.
boole returns the values
specified for any op in the next figure.
 Examples:

(boole booleior 1 16) 17
(boole booleand 2 5) 4
(boole booleeqv 17 15) 31
;;; These examples illustrate the result of applying BOOLE and each
;;; of the possible values of OP to each possible combination of bits.
(progn
(format t "~&Results of (BOOLE <op> #b0011 #b0101) ...~
~%  Op  Decimal  Binary  Bits  ~%")
(dolist (symbol '(boole1 boole2 booleand booleandc1
booleandc2 boolec1 boolec2 booleclr
booleeqv booleior boolenand boolenor
booleorc1 booleorc2 booleset boolexor))
(let ((result (boole (symbolvalue symbol) #b0011 #b0101)))
(format t "~& ~A~13T~3,' D~23T~:*~5,' B~31T ...~4,'0B~%"
symbol result (logand result #b1111)))))
Results of (BOOLE <op> #b0011 #b0101) ...
 Op  Decimal  Binary  Bits 
BOOLE1 3 11 ...0011
BOOLE2 5 101 ...0101
BOOLEAND 1 1 ...0001
BOOLEANDC1 4 100 ...0100
BOOLEANDC2 2 10 ...0010
BOOLEC1 4 100 ...1100
BOOLEC2 6 110 ...1010
BOOLECLR 0 0 ...0000
BOOLEEQV 7 111 ...1001
BOOLEIOR 7 111 ...0111
BOOLENAND 2 10 ...1110
BOOLENOR 8 1000 ...1000
BOOLEORC1 3 11 ...1101
BOOLEORC2 5 101 ...1011
BOOLESET 1 1 ...1111
BOOLEXOR 6 110 ...0110
NIL
 Exceptional Situations:

Should signal typeerror if its first argument is not a
bitwise logical operation specifier or if any subsequent argument is not
an integer.
 See Also:

logand
 Notes:

In general,
(boole booleand x y) ==(logand x y)
Programmers who would prefer to use numeric indices rather than
bitwise logical operation specifiers can get an equivalent effect
by a technique such as the following:
;; The order of the values in this `table' are such that
;; (logand (boole (elt boolenvector n) #b0101 #b0011) #b1111) => n
(defconstant boolenvector
(vector booleclr booleand booleandc1 boole2
booleandc2 boole1 boolexor booleior
boolenor booleeqv boolec1 booleorc1
boolec2 booleorc2 boolenand booleset))
BOOLENVECTOR
(proclaim '(inline boolen))
implementationdependent
(defun boolen (n integer &rest moreintegers)
(apply #'boole (elt boolenvector n) integer moreintegers))
BOOLEN
(boolen #b0111 5 3) 7
(boolen #b0001 5 3) 1
(boolen #b1101 5 3) 3
(loop for n from #b0000 to #b1111 collect (boolen n 5 3))
(0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1)
 Allegro CL Implementation Details:

None.