bit
Functions
std::bit::popcount
std::bit::popcountfn popcount( x);std::bit::has_single_bit
std::bit::has_single_bitfn has_single_bit( x);std::bit::bit_ceil
std::bit::bit_ceilstd::bit::bit_floor
std::bit::bit_floorLast updated
This library contains various helper functions for common bit operations.
std::bit::popcountCalculates the number of 1 bits in a given number
x: The number
return: The number of bits set to 1 in x
fn popcount( x);std::bit::has_single_bitChecks if only a single bit is set to 1 in a given number
x: The number
return: True if there's a single bit set to 1 in x, false otherwise
fn has_single_bit( x);std::bit::bit_ceilRounds the given number up to the next bigger power of two
x: The number
return: Next bigger power of two that can fit x
std::bit::bit_floorRounds the given number down to the next bigger power of two
x: The number
return: Next smaller power of two
Last updated
fn bit_ceil( x);fn bit_floor( x);