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
a = n × q + r, with 0 ≤ r < |n|
- 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
In Python, % already gives the mathematical result.
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.
Last reviewed on 3 October 2026. Found a mistake? Tell us.

