By Debmedia Technologies LLP · Kolkata, India · Updated
What Is It and When Do You Need It?
The modulo operation is behind clocks, calendars, hashing and cryptography. It also trips people up when negative numbers are involved.
Enter two whole numbers.
How to Use This Tool
- Enter or paste your input in the box or boxes above.
- Choose the options, if there are any.
- Press the button to run the tool.
- Read the result and use the copy button where one is shown.
How the Calculation Works
The tool uses exact integer maths. The truncated quotient q rounds toward zero and the remainder is a - b x q. The floored quotient rounds down and the mathematical modulo is a - b x floor(a / b), which always has the sign of b. The check line shows that a = b x q + r.
Worked Example
17 mod 5 gives quotient 3 and remainder 2. -7 mod 3 gives a mathematical modulo of 2 (quotient -3) but a truncated remainder of -1 (quotient -2).
Common Uses
- Programming and hashing.
- Clock arithmetic.
- Checking divisibility.
- Cryptography homework.
Tips and Common Mistakes
- b cannot be zero.
- For clock maths with a 12-hour clock, use b = 12.
- A mod of 0 means a divides evenly by b.
- Check the first result against a case you already know, so you can trust the tool for the rest.
- Nothing you type leaves your device. The work is done by your browser, so it also works with a slow connection once the page has loaded.
Related Tools
Next, you may need the GCD and LCM calculator, prime number checker, Fibonacci calculator, quadratic equation solver.
Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.
Frequently Asked Questions
Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.