Skip to main content

function

is_power_of_two

is_power_of_two(val: Int) -> Bool

Checks if the input value is a power of 2.

Args:

  • val (Int): The input value.

Returns:

True if the input value is a power of 2, False otherwise.

is_power_of_two[type: DType, simd_width: Int](val: SIMD[type, simd_width]) -> SIMD[bool, $1]

Checks if the input value is a power of 2 for each element of a SIMD vector.

Constraints:

The element type of the input vector must be integral.

Parameters:

  • type (DType): dtype used for the computation.
  • simd_width (Int): SIMD width used for the computation.

Args:

  • val (SIMD[type, simd_width]): The input value.

Returns:

A SIMD value where the element at position i is True if the integer at position i of the input value is a power of 2, False otherwise.