Modulo Calculator

QuickCalculators returns a mod b for positive and negative integers, prints the quotient, and shows both floored and truncated remainders when signs differ. The modulo calculator defaults to floored division, the convention used in mathematics and Python, so negative 7 mod 3 equals 2.

01 calculator

Result

    Worked solution

    QuickCalculators returns a mod b for positive and negative integers, prints the quotient, and shows both floored and truncated remainders when signs differ. The modulo calculator defaults to floored division, the convention used in mathematics and Python, so negative 7 mod 3 equals 2.

    Calculate a mod b

    Concept diagram: Inputs leads to a mod b leads to ResultInputsa mod bResult
    Calculate a mod b.

    Enter dividend a and divisor b, pick a convention, and read the remainder on the primary line. Twenty-seven mod 6 equals 3 because 27 minus 4 times 6 leaves 3. Zero divisors block with an error instead of returning NaN.

    Read the two sign conventions

    Concept diagram: Inputs leads to two sign conventions leads to ResultInputstwo sign conventionsResult
    Read the two sign conventions.

    Floored division rounds the quotient toward negative infinity; truncated division rounds toward zero. Positive operands agree; negative operands can disagree by exactly one divisor width. The tool shows the alternate remainder on a secondary line for comparison.

    Floored modulo, used in mathematics and Python

    Floored modulo makes the remainder share the sign of the divisor or zero. Negative 7 mod 3 under flooring uses quotient negative 3, so remainder 2. Congruence statements in number theory assume this form.

    Truncated modulo, used in C, Java and JavaScript

    Truncated modulo uses the truncating quotient toward zero. Negative 7 mod 3 under truncation yields remainder negative 1 because the quotient is negative 2. Switch the radio control to match the language you are debugging.

    Use modulo to test divisibility

    Concept diagram: Inputs leads to modulo to test divisibility leads to ResultInputsmodulo to testdivisibilityResult
    Use modulo to test divisibility.

    When a mod b equals zero with positive b, a is divisible by b. Even tests use mod 2 equals zero. QuickCalculators prints the remainder plainly so you can scan parity without a separate divisibility mode.

    Why 1 mod 2 equals 1

    Concept diagram: Inputs leads to Why 1 mod 2 equals 1 leads to ResultInputsWhy 1 mod 2 equals 1Result
    Why 1 mod 2 equals 1.

    One mod two equals one because 1 is less than the divisor 2, so the quotient is zero and the remainder is the dividend itself. Small dividends often look surprising until you read the quotient line beside the remainder.

    Avoid this common mistake

    Concept diagram: Inputs leads to Avoid this common mistake leads to ResultInputsAvoid this commonmistakeResult
    Avoid this common mistake.

    Many learners expect negative 7 mod 3 to equal negative 1 because their language truncates toward zero. Mathematical floored modulo gives 2. Pick the convention that matches your course or codebase before comparing answers.

    Frequently asked questions

    What does a mod b mean?

    A mod b means the remainder after dividing a by b under the chosen sign convention. The modulo calculator reports that remainder together with the quotient used in the division.

    What is 27 mod 6?

    Twenty-seven mod six equals three because 27 minus 4 times 6 leaves 3. Enter 27 and 6 with floored convention to see quotient 4 and remainder 3.

    What is negative 7 mod 3?

    Negative seven mod three equals two under floored modulo, the default here, because the floored quotient is negative three. Truncated modulo returns negative one instead; the page shows both when signs are negative.

    Why do Python and JavaScript give different modulo results?

    Python and JavaScript give different modulo results on negative dividends because Python floors the quotient while JavaScript truncates toward zero. Match the radio setting to the language under test.

    How do you check if a number is even using modulo?

    To check if a number is even using modulo, test whether the number mod 2 equals zero. An odd number returns remainder one, as with 1 mod 2.

    What is 1 mod 2?

    One mod two equals one because the dividend is smaller than the divisor, so the quotient is zero and the remainder equals the dividend.

    Can the divisor be zero in a modulo operation?

    The divisor cannot be zero in a modulo operation because division by zero is undefined. QuickCalculators returns an error when b equals zero.

    Summary

    QuickCalculators computes remainders with floored or truncated conventions, displays quotient and remainder together, and highlights negative cases such as negative 7 mod 3 equals 2 under flooring. Use modulo two for parity checks and zero remainder tests for divisibility. Align the convention with Python math or C-style languages before comparing outputs.