About this calculator
For negative numbers, maths and most programming languages give different answers; the calculator shows both.
How to use it
- Enter the dividend.
- Enter the divisor.
- Read both results.
The formula
- r
- the mathematical modulo
- %
- truncated remainder in many languages
Worked example
−17 mod 5
- Mathematical modulo: 3, because −17 = 5 × (−4) + 3.
- JavaScript −17 % 5 = −2.
What the result means
The result is always between 0 and the divisor, which is the mathematical convention. In Python, % gives the same answer for a positive divisor; in C, Java and JavaScript a negative dividend gives a negative remainder.
Mathematical modulo and truncated remainder compared
With a negative divisor, this calculator still keeps the answer between 0 and |n|, so 17 mod −5 = 2. Python’s % follows the sign of the divisor instead and gives 17 % −5 = −3, so check which convention your code expects.
| a | n | a mod n (maths) | a % n (C, Java, JavaScript) |
|---|---|---|---|
| 17 | 5 | 2 | 2 |
| −17 | 5 | 3 | −2 |
| −1 | 12 | 11 | −1 |
| −13 | 12 | 11 | −1 |
| −7 | 3 | 2 | −1 |
| −25 | 7 | 3 | −4 |
| 7 | −3 | 1 | 1 |
| 0 | 4 | 0 | 0 |
| 12 | 12 | 0 | 0 |
Everyday uses of modulo
- Day of the week: 100 days after a Monday, 100 mod 7 = 2, so it is a Wednesday.
- 24-hour clock: 9 hours after 20:00 is (20 + 9) mod 24 = 5, that is 05:00.
- Odd or even: n mod 2 is 0 for even numbers and 1 for odd numbers.
- Divisibility: 84 mod 7 = 0, so 84 is a multiple of 7.
Assumptions
- Real numbers.
Limitations
- The divisor cannot be zero.
Frequently asked questions
What is 17 mod 5?
2.
What is −1 mod 12?
11 in mathematics.
Is modulo the same as remainder?
For positive numbers yes; for negatives they can differ.
What is 10 mod 3?
1, because 10 = 3 × 3 + 1.
What is 5 mod 10?
5. When a positive dividend is smaller than the divisor, the dividend itself is the remainder.
Can modulo be used with decimals?
Yes. 7.5 mod 2 = 1.5, because 7.5 = 2 × 3 + 1.5.
Last reviewed on 12 October 2026. How we calculate and check. Found a mistake? Tell us.

