Skip to content

acl/core/bit_manip_utils.h

#include "acl/core/bit_manip_utils.h"

The functions that count, find, and rotate bits.

count_set_bits

uint64_t count_set_bits(uint64_t value)
uint32_t count_set_bits(uint32_t value)
uint16_t count_set_bits(uint16_t value)
uint8_t count_set_bits(uint8_t value)

Counts the number of 1 bits (aka: pop-count).

count_leading_zeros

uint32_t count_leading_zeros(uint32_t value)
uint64_t count_leading_zeros(uint64_t value)

Starting at the MSB, counts the number of leading zeros.

count_trailing_zeros

uint32_t count_trailing_zeros(uint32_t value)
uint64_t count_trailing_zeros(uint64_t value)

Starting at the LSB, counts the number of trailing zeros.

rotate_bits_left

uint32_t rotate_bits_left(uint32_t value, int32_t num_bits)

Rotate the bits left by some amount.

rotate_bits_right

uint32_t rotate_bits_right(uint32_t value, int32_t num_bits)

Rotate the bits right by some amount.

and_not

uint32_t and_not(uint32_t not_value, uint32_t and_value)

Perform: ~not_value & and_value.