Skip to content

daft.functions.pmod#

pmod #

Returns the positive modulo of a by b.

Computes r = a % b; returns r when r >= 0 and (r + b) % b otherwise. Examples: pmod(-7, 3) == 2, pmod(7, -3) == 1, pmod(-7, -3) == -1. Returns NULL when b is 0.

Source code in daft/functions/numeric.py
226
227
228
229
230
231
232
233
def pmod(a: Expression, b: Expression) -> Expression:
    """Returns the positive modulo of ``a`` by ``b``.

    Computes ``r = a % b``; returns ``r`` when ``r >= 0`` and ``(r + b) % b`` otherwise.
    Examples: ``pmod(-7, 3) == 2``, ``pmod(7, -3) == 1``, ``pmod(-7, -3) == -1``.
    Returns NULL when ``b`` is 0.
    """
    return Expression._call_builtin_scalar_fn("pmod", a, b)