Mojo function
log2_floor
log2_floor(val: Int) -> Int
Returns the floor of the base-2 logarithm of an integer value.
Args:
- val (
Int): The input value.
Returns:
Int: The floor of the base-2 logarithm of the input value, which is equal to
the position of the highest set bit. Returns -1 if val is 0 or negative.
log2_floor(val: UInt) -> UInt
Returns the floor of the base-2 logarithm of an integer value.
Args:
- val (
UInt): The input value.
Returns:
UInt: The floor of the base-2 logarithm of the input value, which is equal to
the position of the highest set bit. Returns UInt.MAX if val is 0.
log2_floor[dtype: DType, width: Int, //](val: SIMD[dtype, width]) -> SIMD[dtype, width]
Returns the floor of the base-2 logarithm of an integer value.
Parameters:
- dtype (
DType): Thedtypeof the input SIMD vector. - width (
Int): The width of the input and output SIMD vector.
Args:
- val (
SIMD): The input value.
Returns:
SIMD: The floor of the base-2 logarithm of the input value, which is equal to
the position of the highest set bit. Returns -1 if val is 0 or negative.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!