Modulo Calculator
Find the remainder and quotient of a division, with both truncated and floored modulo.
How it works
remainder = a − b × trunc(a ÷ b) · floored modulo = a − b × ⌊a ÷ b⌋
The modulo operation returns what is left over after division. This calculator shows the truncated remainder produced by the % operator, whose sign follows the dividend, alongside the floored modulo, whose sign follows the divisor — the two differ only when negative numbers are involved. The quotient counts how many whole times the divisor fits.
Worked example
17 mod 5 is 2, because 5 goes into 17 three whole times (15) leaving 2 left over. Here the truncated and floored results agree at 2; they would differ only if the dividend were negative.
Frequently asked questions
What is the modulo operation?
It returns the remainder after dividing one number by another. 17 mod 5 is 2, because 17 is three full fives (15) with 2 left over.
Why are there two different remainders for negative numbers?
The truncated remainder, what the % operator gives, takes the sign of the dividend, so −17 % 5 is −2. The floored remainder always takes the sign of the divisor, giving 3. Both are correct under different conventions.
What is modulo used for?
Wrapping values around a cycle: clock arithmetic (hours mod 12), testing even or odd (n mod 2), cycling through a list, and checking divisibility all rely on it.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.