bitmath#
Bit-twiddling functions of unsigned integers
Functions
|
Check if all specified bits in an integer are set to 1. |
|
Flip the value of a specific bit in an integer. |
|
Flip the values of multiple specific bits in an integer. |
|
Get the value of a specific bit in an integer. |
|
Get the integer representation of a bitmask with bits set at the specified indices. |
|
Insert a bit value at a specific index in an integer. |
|
Check if a number is a power of 2. |
|
Calculate the base-2 logarithm of a power-of-2 number. |
|
Calculate 2 raised to the power of the given exponent. |
- all_bits_are_one(number: int, bit_indices: list[int]) bool[source]#
Check if all specified bits in an integer are set to 1.
- flip_bit(number: int | Tensor, bit_index: int) int | Tensor[source]#
Flip the value of a specific bit in an integer.
- flip_bits(number: int | Tensor, bit_indices: list[int]) int | Tensor[source]#
Flip the values of multiple specific bits in an integer.
- get_bit(number: int | Tensor, bit_index: int) int | Tensor[source]#
Get the value of a specific bit in an integer.
- get_bit_mask(bit_indices: list[int]) int[source]#
Get the integer representation of a bitmask with bits set at the specified indices.