Modulo Calculator
Find remainders with correct handling of negative numbers.
-17 mod 5
3
JavaScript % operator gives
-2
Quotient (floored)
-4
Clock arithmetic
Modulo keeps the remainder after division — 17 mod 5 is 2, and clocks are mod 12: 9 + 5 o'clock wraps to 2. The mathematical convention keeps results in 0…n−1 even for negatives: −17 mod 5 is 3, since −17 = −4×5 + 3.
The negative-number trap
Most programming languages' % operator returns −2 for −17 % 5, following the dividend's sign — a classic off-by-wrap bug in calendars and array indexing. The fix shown here, ((a % n) + n) % n, is a rite of passage.
Related calculators
Percentage Calculator
Solve any percentage problem: percent of, percent change, and more.
Fraction Calculator
Add, subtract, multiply, and divide fractions with simplified results.
Scientific Calculator
A full scientific calculator with trig, logs, and exponents.
Random Number Generator
Generate random numbers in any range, with or without repeats.