Modulo looks like the simplest operation in programming — just the remainder after division — until a negative number shows up and your language disagrees with the one next to it. This calculator shows every answer at once so you always know which convention you are looking at, and adds modular exponentiation for the cryptography and hashing cases where modulo really earns its keep.
The remainder is not unique — the quotient decides it
Division of integers produces a quotient and a remainder linked by one identity: a = q·n + r. The catch is that this single equation has more than one integer solution once signs get involved. Pin down how you round the quotient and the remainder follows automatically.
Round the quotient toward zero (truncated division) and the remainder ends up with the sign of the dividend a. Round it toward negative infinity (floored division) and the remainder takes the sign of the divisor n. Insist that the remainder be non-negative and you get the Euclidean convention used throughout mathematics. None of these is 'wrong' — they are three internally consistent answers to a genuinely ambiguous question.
Why JavaScript and Python disagree
-7 % 3 is -1 in JavaScript, C, C++, Java, Go, and Rust, but 2 in Python and Ruby. The C-family languages standardized on truncated division decades ago, so their % keeps the sign of the dividend. Python's designers chose floored division because it makes % behave nicely for the most common real use — wrapping an index into a fixed range — where you almost always want a non-negative result.
This is a frequent source of bugs when porting code or calling across language boundaries. A pattern like arr[i % len] is safe in Python even when i is negative, but in JavaScript it can index with a negative number. The portable fix is to force the Euclidean result explicitly: ((i % len) + len) % len.
Where modulo actually matters: clocks, hashing, and crypto
Wrap-around math. Clocks (mod 12 or 24), weekdays (mod 7), and angles (mod 360) are all Euclidean modulo. Anything that cycles is a modulo in disguise.
Hashing and load balancing. Hash tables place a key in bucket hash(key) mod numBuckets. Because hashes are often signed, this is exactly where the negative-remainder bug bites — and why the Euclidean convention is what you want for a valid bucket index.
Cryptography. RSA and Diffie-Hellman are built on modular exponentiation: raising a number to a large power modulo a large number. Computing the power directly is impossible (the intermediate values would have astronomically many digits), so the fast square-and-multiply method reduces modulo m after every step. The Modular Exponentiation tab in this calculator runs that exact algorithm over BigInt.