chickadee » srfi-60 » bit-count

logcount nprocedure
bit-count nprocedure

Returns the number of bits in integer n. If integer is positive, the 1-bits in its binary representation are counted. If negative, the 0-bits in its two's-complement binary representation are counted. If 0, 0 is returned.

Example:

(logcount #b10101010)
   ; => 4
(logcount 0)
   ; => 0
(logcount -2)
   ; => 1