Modulo Calculator
Calculate a mod n and the quotient online, with correct handling of negative numbers. See both the truncated remainder and the floored mathematical modulo.
How it was computed
-7 % 3 = -1 (truncated, keeps sign of dividend)
((-7 % 3) + 3) % 3 = 2 (floored, matches sign of divisor)
What is the Modulo Calculator?
The ByteTools Modulo Calculator computes the remainder of a divided by n, along with the quotient. Crucially, it shows both conventions for negative numbers: the truncated remainder that most programming languages return and the floored, always-non-negative modulo used in mathematics.
- Remainder and quotient of a ÷ n
- Truncated remainder (JavaScript % behaviour)
- Floored mathematical modulo, always non-negative
- Correct, explicit handling of negative operands
- Guards against a zero divisor
- 100% private — runs entirely in your browser
How to use the Modulo Calculator
- 1
Enter the dividend a.
- 2
Enter the divisor n (the modulus).
- 3
Read the truncated remainder as returned by most languages.
- 4
Compare the floored, mathematical modulo and the quotient.
- 5
Click Copy to grab the results.
About the Modulo Calculator
The ByteTools Modulo Calculator computes the remainder of a divided by n, along with the quotient. Crucially, it shows both conventions for negative numbers: the truncated remainder that most programming languages return and the floored, always-non-negative modulo used in mathematics.
It is aimed at programmers, students and anyone who has been caught out by −7 mod 3 giving different answers in different languages. Seeing both results side by side removes the confusion and explains which convention each uses.
Every calculation runs in your browser with JavaScript. No numbers are uploaded, so the tool is private, instant and works offline. Copy the results with one click.
Frequently asked questions
What is the modulo operation?
Modulo gives the remainder after dividing one number by another. For 17 mod 5, seventeen divided by five is three remainder two, so the result is 2. It is widely used for cycles, hashing and checking divisibility.
Why do negative numbers give different modulo results?
There are two conventions. The truncated version, used by JavaScript and C, keeps the sign of the dividend, so −7 % 3 = −1. The floored version, used in Python and mathematics, matches the sign of the divisor, so −7 mod 3 = 2. This tool shows both.
What is the difference between remainder and modulo?
For positive numbers they are identical. They differ only when negatives are involved: the remainder follows truncated division while the mathematical modulo follows floored division. The calculator labels each clearly so you pick the right one.
What happens when you divide by zero?
Modulo by zero is undefined, just like division by zero, because there is no meaningful remainder. The calculator detects a zero divisor and shows a message instead of returning an invalid result.
How do I get an always-positive modulo?
Use the floored convention, which this tool computes as ((a % n) + n) % n. It always returns a value between 0 and n − 1, which is what you usually want for array indexing and clock arithmetic.
Guides for Modulo Calculator
Related tools
GCD & LCM Calculator
Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers using Euclid's algorithm, with the working shown.
Prime Number Checker
Check whether a number is prime or composite. See the smallest factor and the full list of factors for any integer up to billions, instantly and privately.
Binary Calculator
Do arithmetic and bitwise math on binary, decimal, hex and octal numbers — add, subtract, multiply, divide, AND, OR, XOR and shifts, with results in all bases.
Prime Factorization Calculator
Find the prime factorization of any integer. See the prime factors with exponents and the product form like 2² × 3 × 5, calculated instantly in your browser.
Exponent Calculator
Calculate base raised to any exponent online, including negative and fractional powers. See the result and the full expression, computed instantly in your browser.