Modulo Calculator
Enter a dividend and a divisor to get the modulo. Both sign conventions are shown, so negative numbers are unambiguous.
How to use this calculator
- Enter the dividend — the number being divided.
- Enter the divisor, also called the modulus.
- Read the result. The check line multiplies the quotient back out and adds the remainder, so you can confirm it lands on your dividend.
The truncated row is worth a glance whenever either number is negative. It says whether the other convention would have given a different answer, which is the usual cause of a disagreement between two tools.
How modulo is calculated
Modulo is division with the quotient thrown away and the leftover kept. The definition is a rearrangement of ordinary division.
- a — the dividend, e.g. 250
- n — the divisor or modulus, e.g. 24
- floor — round down, toward negative infinity
Equivalently, a = qn + r: there is a whole number q such that the divisor times q plus the remainder gives the dividend back. For 250 and 24 that is24 × 10 + 10 = 250.
Modulo with negative numbers
This is where the two conventions split. Flooring rounds the quotient down; truncating rounds it toward zero. For positive numbers those are the same thing, so the disagreement only appears once a minus sign does.
| Expression | Floored | Truncated |
|---|---|---|
| 10 mod 3 | 1 | 1 |
| 250 mod 24 | 10 | 10 |
| 100 mod 7 | 2 | 2 |
| −9 mod 4 | 3 | −1 |
| 9 mod −4 | −3 | 1 |
The first three rows agree. The last two are the same two numbers with a minus sign moved, and the two conventions give different answers to both. Under flooring the result always takes the sign of the divisor, which is the behaviour clock arithmetic needs: three hours before 12 o'clock should be 9, not −3.