Math
Instant, private, and free
Modulo Calculator.
Calculate a remainder and compare signed remainder with mathematical non-negative modulo.
Set your values
Results update as you type.
How to Use
Enter a dividend and a non-zero divisor. Results update as you type.
JavaScript remainder (%) truncates the quotient toward zero and follows the dividend's sign.
Mathematical modulo is always between 0 (inclusive) and the absolute divisor (exclusive), including for negative inputs.
FAQs
What is the difference between remainder and modulo?
A signed remainder follows the dividend's sign, while mathematical modulo is normalized to a non-negative value below the absolute divisor.
Can the divisor be negative?
Yes. The signed remainder follows JavaScript's operator semantics, while mathematical modulo uses the absolute divisor for its non-negative range.
Use Cases
Check remainder in programming
Quickly verify how JavaScript's % operator behaves with negative numbers, and compare it to the mathematical modulo for algorithm design.
Example: Check -7 % 3 vs -7 mod 3 to see -1 vs 2.
Learn modulo arithmetic
Understand the difference between signed remainder and non-negative modulo, useful for math homework or teaching.
Example: See that 10 mod 4 = 2, but -10 mod 4 = 2 (mathematical) vs -2 (JavaScript).
Frequently Asked Questions
- What is the difference between JavaScript's remainder and mathematical modulo?
- JavaScript's remainder operator (%) returns a result with the sign of the dividend, so -5 % 3 gives -2. Mathematical modulo returns a non-negative result, so -5 mod 3 gives 1. This calculator shows both for comparison.
- How do I use this modulo calculator?
- Enter a dividend and a divisor. The calculator will compute the remainder (JavaScript style) and the mathematical modulo (non-negative). It also shows the quotient and the division equation.
- Can this calculator handle negative divisors?
- Yes, it handles negative divisors. The mathematical modulo is always non-negative, while the JavaScript remainder takes the sign of the dividend. The calculator displays both results clearly.
Tips & Common Mistakes
Tips
- Remember: JavaScript's % gives the remainder, not the mathematical modulo. For negative dividends, results differ.
- Use the mathematical modulo when you need a result in the range [0, divisor-1], common in cyclic calculations.
- Check both results to avoid bugs in code that relies on non-negative remainders.
- The divisor cannot be zero; division by zero is undefined.
Common Mistakes to Avoid
- Assuming JavaScript's % always returns a non-negative result; it returns the sign of the dividend.
- Confusing the remainder with the modulo when dealing with negative numbers; they are not the same.
- Forgetting that the divisor cannot be zero; entering zero will cause an error.
Last updated: August 13, 2026