Skip to main content

function

bit_length

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

Computes the number of digits required to represent the integer.

Constraints:

The function asserts on non-integral dtypes in debug builds and returns 0 in release builds.

Parameters:

  • type (DType): dtype used for the computation. Constraints: must be integral.
  • 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 equals to the number of digits required to represent the integer at position i of the input value.