CountBits

Counts the number of bits set in a word.

Synopsis

int CountBits(uint32 mask);

Description

CountBits examines the longword passed in as a parameter and returns the number of bits that are turned on in the word, using an algorithm derived from a note in MIT's HAKMEM.

Arguments

mask
The data word to count the bits of.

Return Value

The number of bits that were turned on in the supplied value.

Implementation

Convenience call implemented in clib.lib V21.

Associated Files

string.h
ANSI C Prototype
clib.lib
ARM Link library

See Also

FindMSB(), FindLSB()