
ANSI Common Lisp 12 Numbers 12.2 Dictionary of Numbers
12.2.64 logcount 
Function 
 Syntax:

logcount
integer
numberofonbits
 Arguments and Values:

integer  an integer.
numberofonbits  a nonnegative integer.
 Description:

Computes and returns the number of bits
in the two'scomplement binary representation of integer
that are `on' or `set'.
If integer is negative, the 0 bits are counted;
otherwise, the 1 bits are counted.
 Examples:

(logcount 0) 0
(logcount 1) 0
(logcount 7) 3
(logcount 13) 3 ;Two'scomplement binary: ...0001101
(logcount 13) 2 ;Two'scomplement binary: ...1110011
(logcount 30) 4 ;Two'scomplement binary: ...0011110
(logcount 30) 4 ;Two'scomplement binary: ...1100010
(logcount (expt 2 100)) 1
(logcount ( (expt 2 100))) 100
(logcount ( (1+ (expt 2 100)))) 1
 Exceptional Situations:

Should signal typeerror if its argument is not an integer.
 Notes:

Even if the implementation does not represent integers internally
in two's complement binary, logcount behaves as if it did.
The following identity always holds:
(logcount x)
==(logcount ( (+ x 1)))
==(logcount (lognot x))
 Allegro CL Implementation Details:

None.
