Modulo Calculator
Find the remainder (a mod b), with both truncated and floored conventions.
The modulo is the remainder after dividing a by b. With negative numbers the answer differs by convention: the "truncated" remainder (used by JavaScript, C and Java) takes the dividend's sign, while the mathematical "floored" mod takes the divisor's sign. Both are shown when they differ. Runs in your browser.
Find a mod b — the remainder left after dividing a by b. The calculator shows the quotient and, for negative numbers, both common conventions: the truncated remainder used by JavaScript, C and Java (sign follows the dividend) and the mathematical floored mod (sign follows the divisor). Runs in your browser.
How to use the Modulo Calculator
- Enter the dividend (a) and the divisor (b).
- Read a mod b and the quotient.
- For negatives, compare the truncated and floored results.
Frequently asked questions
What is the modulo operation?
Modulo gives the remainder after integer division. For example 17 mod 5 = 2, because 17 = 3 × 5 + 2.
Why do negative numbers give different answers?
Languages disagree: the truncated remainder (JavaScript, C, Java) takes the dividend's sign, while the mathematical floored mod takes the divisor's sign. −7 mod 3 is −1 truncated but 2 floored.