Skip to main content

Mojo function

udivmod_unchecked

udivmod_unchecked(a: Int, b: Int) -> Tuple[Int, Int]

Unsigned divmod without zero-guard.

Unlike udivmod, this uses UInt.__truediv__ (pop.div) which emits a raw unsigned division without the zero-guard (icmp eq 0 + umax + select) that UInt.__floordiv__ and UInt.__mod__ insert. This produces tighter codegen on GPUs where the guard is unnecessary overhead.

The caller must guarantee that b > 0. Behavior is undefined otherwise.

Args:

  • a (Int): The dividend (must be non-negative).
  • b (Int): The divisor (must be positive).

Returns:

Tuple: A Tuple of (quotient, remainder) from unsigned division.

Was this page helpful?