bit-count ( obj -- n )
Factor handbook > The language > Numbers > Arithmetic > Bitwise arithmetic > Additional bitwise arithmetic

Prev:on-bits ( m -- n )
Next:even-parity? ( obj -- ? )


Vocabulary
math.bitwise

Inputs and outputs
objan object
nan integer


Word description
Returns the number of set bits as an object. This word only works on non-negative integers or objects that can be represented as a byte-array.

Examples
USING: math.bitwise prettyprint ; 0xf0 bit-count .
4

USING: math.bitwise prettyprint ; -1 32 bits bit-count .
32

USING: math.bitwise prettyprint ; B{ 1 0 1 } bit-count .
2


Definition


Methods