std.bits
bit twiddling on u32/u64
count_ones_u32
Section titled “count_ones_u32”pub count_ones_u32 :: fn(value: u32) -> u32count set bits; kernighan’s loop, one pass per 1-bit
count_ones_u64
Section titled “count_ones_u64”pub count_ones_u64 :: fn(value: u64) -> u32leading_zeros_u32
Section titled “leading_zeros_u32”pub leading_zeros_u32 :: fn(value: u32) -> u32leading_zeros_u64
Section titled “leading_zeros_u64”pub leading_zeros_u64 :: fn(value: u64) -> u32trailing_zeros_u32
Section titled “trailing_zeros_u32”pub trailing_zeros_u32 :: fn(value: u32) -> u32trailing_zeros_u64
Section titled “trailing_zeros_u64”pub trailing_zeros_u64 :: fn(value: u64) -> u32rotate_left_u32
Section titled “rotate_left_u32”pub rotate_left_u32 :: fn(value: u32, amount: u32) -> u32rotate_right_u32
Section titled “rotate_right_u32”pub rotate_right_u32 :: fn(value: u32, amount: u32) -> u32rotate_left_u64
Section titled “rotate_left_u64”pub rotate_left_u64 :: fn(value: u64, amount: u32) -> u64rotate_right_u64
Section titled “rotate_right_u64”pub rotate_right_u64 :: fn(value: u64, amount: u32) -> u64is_power_of_two_u32
Section titled “is_power_of_two_u32”pub is_power_of_two_u32 :: fn(value: u32) -> boolis_power_of_two_u64
Section titled “is_power_of_two_u64”pub is_power_of_two_u64 :: fn(value: u64) -> boolbit_u32
Section titled “bit_u32”pub bit_u32 :: fn(value: u32, index: u32) -> boolset_bit_u32
Section titled “set_bit_u32”pub set_bit_u32 :: fn(value: u32, index: u32) -> u32clear_bit_u32
Section titled “clear_bit_u32”pub clear_bit_u32 :: fn(value: u32, index: u32) -> u32toggle_bit_u32
Section titled “toggle_bit_u32”pub toggle_bit_u32 :: fn(value: u32, index: u32) -> u32