Number of ``on'' bits in a two's complement number
(Logcount x) is the number of ``on'' bits in the two's
complement representation of x.
(Logcount x) has a guard of (integerp x).
Logcount is a Common Lisp function. See any Common Lisp documentation
for more information.
(defun logcount (x)
(declare (xargs :guard (integerp x)))
(cond ((zip x) 0)
((< x 0) (logcount (lognot x)))
(logcount (nonnegative-integer-quotient x 2)))
(t (1+ (logcount (nonnegative-integer-quotient x 2))))))