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.
How to Use the Modulo Calculator
Enter a dividend and non-zero divisor, then choose the remainder convention you need.
- Enter the dividend.
- Enter a non-zero divisor.
- Choose signed remainder or mathematical modulo.
Remainder and Modulo
Remainder
The signed remainder follows the dividend under JavaScript's remainder convention.
Example:
Input: a = -17, b = 5
Calculation: -17 % 5
Result: -2
Mathematical modulo
The mathematical result is normalized to a non-negative half-open interval.
Example:
Input: a = -17, b = 5
Calculation: -17 mod 5
Result: 3
Common Use Cases
Modulo is useful for repeating indexes, cycles, and discrete arithmetic.
Repeating indexes
Wrap a position into a fixed-size array or cycle.
Remainder checks
Check whether a number divides evenly or leaves a remainder.
Choose the Convention
Tips
- A divisor of zero is undefined.
- JavaScript remainder and mathematical modulo differ for negative dividends.
- The mathematical result is always below the absolute divisor.
Common Mistakes to Avoid
- Assuming every programming language uses the same negative-number convention.
- Using a zero divisor.
Related Resources
Related Calculators
Cite this calculator
Canonical URL: https://mathify.one/en/math/modulo
Cite as: Mathify. (2026). Modulo Calculator. https://mathify.one/en/math/modulo
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