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

umod

def umod(a: Int, b: Int) -> Int

Perform unsigned modulo (%) on Int arguments.

This function treats both arguments as unsigned values and performs unsigned modulo, which is faster than signed modulo on NVIDIA GPUs.

For correctness, both arguments should be non-negative integers.

Args:

  • a (Int): The dividend (treated as unsigned).
  • b (Int): The divisor (treated as unsigned).

Returns:

Int: The remainder of unsigned division.

def umod[dtype: DType, width: Int, //](a: SIMD[dtype, width], b: SIMD[dtype, width]) -> SIMD[dtype, width]

Perform unsigned modulo (%) on SIMD arguments.

This function reinterprets both arguments as unsigned values of the same bit width and performs unsigned modulo, which is faster than signed modulo on NVIDIA GPUs.

For correctness, both arguments should be non-negative integers.

Constraints:

dtype must be an integral type.

Parameters:

  • dtype (DType): The integral data type of the operands.
  • width (Int): The number of elements in each SIMD vector.

Args:

Returns:

SIMD[dtype, width]: The elementwise remainder of unsigned division.