"""Arithmetic monomers — wrapping 8-bit unsigned."""


def add8(a: int, b: int) -> int:
    return (a + b) & 0xFF


def sub8(a: int, b: int) -> int:
    return (a - b) & 0xFF


def mul8(a: int, b: int) -> int:
    return (a * b) & 0xFF


def div8(a: int, b: int) -> tuple[int, int]:
    if b == 0:
        raise ZeroDivisionError("div8: division by zero")
    return (a // b, a % b)


def mod8(a: int, b: int) -> int:
    if b == 0:
        raise ZeroDivisionError("mod8: division by zero")
    return (a % b) & 0xFF


def inc(a: int) -> int:
    return (a + 1) & 0xFF


def dec(a: int) -> int:
    return (a - 1) & 0xFF


def abs8(a: int) -> int:
    return a & 0xFF
