Comprehensive Calculator Guide
This calculator gives the integer quotient and remainder of any two integers, negatives included, in mod notation. 17 ÷ 5 = 3 remainder 2, so 17 mod 5 = 2. It also explains why −17 mod 5 is 3 in maths but −2 in JavaScript.
Remainders
For integers a and b ≠ 0 there are unique q and r with a = bq + r and 0 ≤ r < |b|. Languages like JavaScript, C and Java truncate toward zero and can return negative remainders; Python matches the maths.
How to Use
- Enter the dividend.
- Enter a non-zero divisor.
- Press “Calculate” to see the remainder, quotient and the programming remainder if different.
Formula Used
a = b × q + r, 0 ≤ r < |b|
Practical Examples
- Example 1
- 17 ÷ 5 = 3 r 2.
- Example 2
- −17 ÷ 5: q = −4, r = 3 (JavaScript gives −2).
- Example 3
- 100 ÷ 7 = 14 r 2.
Important Tips
- Use mod 7 for weekdays.
- Check: b × q + r = a.
- Mind negatives in code.
Common Mistakes to Avoid
- A remainder ≥ the divisor.
- Expecting every language to agree on negatives.
- Confusing remainder with decimals.
Frequently Asked Questions
- What does 17 mod 5 mean?
- The remainder, 2.
- How do I find it by hand?
- Subtract divisor × quotient from the dividend.
- Why do programs differ?
- They round the quotient differently.