Skip to main content

module

bit

Provides functions for bit manipulation.

You can import these APIs from the bit package. For example:

from bit import countl_zero

Functions

  • countl_zero: Counts the number of leading zeros of an integer.
  • countr_zero: Counts the number of trailing zeros for an integer.
  • bit_reverse: Element-wise reverses the bitpattern of a SIMD vector of integer values.
  • byte_swap: Byte-swaps a SIMD vector of integer values with an even number of bytes.
  • pop_count: Counts the number of bits set in a SIMD vector of integer values.
  • bit_not: Performs a bitwise NOT operation on an SIMD vector of integer values.
  • bit_width: Computes the minimum number of bits required to represent the integer.
  • is_power_of_two: Checks if the input value is a power of 2.
  • 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.
  • rotate_bits_left: Shifts the bits of an input to the left by shift bits (with wrap-around).
  • rotate_bits_right: Shifts the bits of an input to the right by shift bits (with wrap-around).