Modulo Calculator

    Calculate a mod b and compare JavaScript-style remainder with Python-style modulo for positive, negative, integer, and decimal inputs.

    Examples:

    Modulo and remainder intent

    English SERPs mix two intents: a basic a mod b calculator for positive integers, and developer-style questions about negative numbers. This tool keeps both results visible so the difference is explicit.

    For a truncated remainder, q is truncated toward zero. For Python-style modulo, q is floored.

    1. Use the main answer for JavaScript, C, and Java-style remainder behavior.
    2. Use the Python-style row when the modulo result should follow the divisor sign.
    3. For positive integers, both methods usually return the same value.

    Negative number behavior

    ExpressionTruncated remainderPython-style modulo
    13 mod 533
    -13 mod 5-32
    13 mod -53-2
    Division by zero is undefined, so the divisor cannot be 0.

    Frequently Asked Questions

    Sources and References

    Calculations are based on the listed reference sources. Links open in a new tab.

    Updated:

    Related Tools