Skip to main content

Mojo function

udiv_unchecked

udiv_unchecked(a: Int, b: Int) -> Int

Unsigned division without zero-guard.

Unlike ufloordiv, this uses UInt.__truediv__ (pop.div) which emits a raw unsigned division without the zero-guard that UInt.__floordiv__ inserts. 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:

Int: The quotient of unsigned division.

Was this page helpful?