Previous: OS Library, Up: Function Descriptions


7.1.6 Bit-manipulation Library

The following functions are provided as fast implementations of low-level bitwise manipulation functions.

— Function: parity int

Returns parity of int, true if odd-parity, false if even-parity.

— Function: popcount int

Returns the number of set bits in the binary representation of int.

— Function: clz32 int

Returns the number of leading 0s in the 32b binary representation of int. (Leading 0s are in the more significant bit positions.) Result is undefined if int is 0.

— Function: ctz int

Returns the number of trailing 0s in the binary representation of int. (Trailing 0s are in the less significant bit positions.) Result is undefined if int is 0.

— Function: ffs int

Returns the 1-indexed position of the first set bit in the binary representation of int. Position is counted from the least significant bits. Returns 0 if int is 0.

— Function: msb int

Return the 0-indexed position of the most significant bit. Undefined for int 0.

— Function: lsb int

Return the 0-indexed position of the least significant bit. Undefined for int 0.