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).

count_trailing_zeros

count_trailing_zeros(val: Int) -> Int

Counts the number of trailing zeros for an integer.

Args:

  • val (Int): The input value.

Returns:

Int: The number of trailing zeros of the input.

count_trailing_zeros[dtype: DType, width: Int, //](val: SIMD[dtype, width]) -> SIMD[dtype, width]

Counts the per-element number of trailing zeros in a SIMD vector.

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:

Returns:

SIMD[dtype, width]: A SIMD value where the element at position i contains the number of trailing zeros at position i of the input value.