A little context. A clearer answer.
When this calculator is useful
Find the nonnegative remainder and floor quotient for integer division by a positive modulus. Enter your values and inspect the calculation details. For a related calculation, try GCD & LCM Calculator for Multiple Numbers.
What to enter
| Input | What it means | Example value |
|---|---|---|
| Integer dividend a | Signed whole integer a, with no decimal point or grouping separators. | -17 |
| Positive modulus m | Strictly positive whole integer m. | 5 |
How the calculation works
- Take q = floor(a/m).
- Calculate r = a − qm; this guarantees 0 ≤ r < m.
- Verify the exact identity a = qm + r and inspect the remainder within one modulus interval.
a = qm + r; q = floor(a/m); 0 ≤ r < m; m > 0A worked example
Worked example: −17 = (−4) × 5 + 3, so the remainder is 3.
Example you can load
What to enterThis is a fixed example; changing the form above does not change these numbers.
Assumptions & limits
Each integer may contain at most 80 digits. The modulus must be positive. This is Euclidean modulo, which can differ from a programming language’s signed remainder operator.
Frequently asked questions
Why is −17 modulo 5 equal to 3?
The floor quotient is −4, so −17 = (−4) × 5 + 3.
Can the modulus be negative or zero?
No. This tool uses the positive-modulus Euclidean convention.
Is this the same as the % operator?
Not in every language. Some operators use truncation and return a negative remainder for negative dividends.