def remainder(x, y, context=None):
    """
    Return x reduced modulo y.

    Returns the value of x - n * y, where n is the integer quotient of x
    divided by y, rounded to the nearest integer (ties rounded to even).

    Special values are handled as described in Section F.9.7.1 of the ISO C99
    standard: If x is infinite or y is zero, the result is NaN. If y is
    infinite and x is finite, the result is x (rounded to the current
    context). If the result is zero, it has the sign of x.

    """
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_remainder,
        (
            BigFloat._implicit_convert(x),
            BigFloat._implicit_convert(y),
        ),
        context,
    )