Mojo module
bit
Provides functions for bit manipulation.
You can import these APIs from the bit
package. For example:
from bit import count_leading_zeros
from bit import count_leading_zeros
Functionsβ
- β
bit_ceil
: Computes the smallest power of 2 that is greater than or equal to the input value. Any integral value less than or equal to 1 will be ceiled to 1. - β
bit_floor
: Computes the largest power of 2 that is less than or equal to the input value. Any integral value less than or equal to 0 will be floored to 0. - β
bit_not
: Performs a bitwise NOT operation on an SIMD vector of integer values. - β
bit_reverse
: Reverses the bitpattern of an integer value. - β
bit_width
: Computes the minimum number of bits required to represent the integer. - β
byte_swap
: Byte-swaps an integer value with an even number of bytes. - β
count_leading_zeros
: Counts the number of leading zeros of an integer. - β
count_trailing_zeros
: Counts the number of trailing zeros for an integer. - β
is_power_of_two
: Checks if the input value is a power of 2. - β
pop_count
: Counts the number of bits set in an integer value. - β
rotate_bits_left
: Shifts the bits of an input to the left byshift
bits (with wrap-around). - β
rotate_bits_right
: Shifts the bits of an input to the right byshift
bits (with wrap-around).
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
π What went wrong?