Skip to main content
Log in

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:

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.