IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

circular_add

def circular_add[n: Int](x: Int, y: Int) -> Int

Addition modulo n, assuming 0 <= x < n and 0 <= y < n.

Equivalent to (x + y) % n. When n is a power of 2, uses unsigned modulo which compiles to a single and instruction. Otherwise uses a conditional subtract to avoid expensive integer division on GPU.

Returns:

Int