IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

log2_ceil

log2_ceil(val: Int) -> Int

Returns the ceiling of the base-2 logarithm of an integer value.

Args:

  • val (Int): The input value.

Returns:

Int: The ceiling of the base-2 logarithm of the input value, which corresponds to the smallest power of 2 greater than or equal to the input. Returns 0 if val is 0.

log2_ceil(val: Scalar) -> Scalar[val.dtype]

Returns the ceiling of the base-2 logarithm of an integer value.

Args:

  • val (Scalar): The input value.

Returns:

Scalar[val.dtype]: The smallest integer n such that 2^n is greater than or equal to the input value. Returns 0 if val is 0.