Go to the first, previous, next, last section, table of contents.
These functions operate on the bit string which an integer is made of.
- Function: lsh number count
-
This function bit-shifts the integer number count bits to the
left, if count is negative number is shifted to the right
instead.
(lsh 1 8)
=> 256
(lsh 256 -8)
=> 1
- Function: ash number count
-
Similar to
lsh except that an arithmetical shift is done, this means
that the sign of number is always preserved.
(ash 1 8)
=> 256
(ash -1 2)
=> -4
- Function: logand number1 &rest numbers
-
This function uses a bit-wise logical `and' operation to combine all its
arguments (there must be at least one argument).
(logand 15 8)
=> 8
(logand 15 7 20)
=> 4
- Function: logior number1 &rest numbers
-
Uses a bit-wise logical `inclusive-or' to combine all its arguments (there
must always be at least one argument).
(logior 1 2 4)
=> 7
- Function: logxor number1 &rest numbers
-
Uses a bitwise logical `exclusive-or' to combine all its arguments
(there must be at least one).
(logxor 7 3)
=> 4
- Function: lognot number
-
This function inverts all the bits in number.
(lognot 0)
=> -1
(lognot 2)
=> -3
(lognot -1)
=> 0
Go to the first, previous, next, last section, table of contents.