Mojo function
bit_width
bit_width(val: Int) -> Int
Computes the minimum number of bits required to represent the integer.
Args:
- val (
Int
): The input value.
Returns:
The number of bits required to represent the integer.
bit_width[dtype: DType, width: Int, //](val: SIMD[dtype, width]) -> SIMD[dtype, width]
Computes the minimum number of bits required to represent each element of a SIMD vector of integer values.
Constraints:
The element type of the input vector must be integral.
Parameters:
- dtype (
DType
):dtype
used for the computation. - width (
Int
): SIMD width used for the computation.
Args:
- val (
SIMD[dtype, width]
): The input value.
Returns:
A SIMD value where the element at position i
equals the number of bits required to represent the integer at position i
of the input.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!