IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

rotate_bits_left

rotate_bits_left[shift: Int](x: Int) -> Int

Shifts the bits of an input to the left by shift bits (with wrap-around).

Constraints:

-size <= shift < size

Parameters:

  • shift (Int): The number of bit positions by which to rotate the bits of the integer to the left (with wrap-around).

Args:

  • x (Int): The input value.

Returns:

Int: The input rotated to the left by shift elements (with wrap-around).

rotate_bits_left[dtype: DType, width: Int, //, shift: Int](x: SIMD[dtype, width]) -> SIMD[dtype, width] where dtype.is_unsigned()

Shifts bits to the left by shift positions (with wrap-around) for each element of a SIMD vector.

Constraints:

0 <= shift < size

Parameters:

  • dtype (DType): The dtype of the input and output SIMD vector. Must be integral and unsigned.
  • width (Int): The width of the SIMD vector.
  • shift (Int): The number of positions to rotate left.

Args:

Returns:

SIMD[dtype, width]: SIMD vector with each element rotated left by shift bits.