Modulo Calculator

Enter a dividend and a divisor to get the modulo. Both sign conventions are shown, so negative numbers are unambiguous.

Your division

The number being divided.
The number you are dividing by — the modulus.
Working
250 − 24 × 10 = 10
Convention
Floored — the result takes the sign of the divisor
250 mod 24
10
Truncated remainder
10 — same
Quotient (floored)
10
Check
24 × 10 + 10 = 250
Congruence
250 ≡ 10 (mod 24)

How to use this calculator

  1. Enter the dividend — the number being divided.
  2. Enter the divisor, also called the modulus.
  3. Read the result. The check line multiplies the quotient back out and adds the remainder, so you can confirm it lands on your dividend.

The truncated row is worth a glance whenever either number is negative. It says whether the other convention would have given a different answer, which is the usual cause of a disagreement between two tools.

How modulo is calculated

Modulo is division with the quotient thrown away and the leftover kept. The definition is a rearrangement of ordinary division.

a mod n = a − n × floor(a ÷ n)
  • a — the dividend, e.g. 250
  • n — the divisor or modulus, e.g. 24
  • floor — round down, toward negative infinity

Equivalently, a = qn + r: there is a whole number q such that the divisor times q plus the remainder gives the dividend back. For 250 and 24 that is24 × 10 + 10 = 250.

Modulo with negative numbers

This is where the two conventions split. Flooring rounds the quotient down; truncating rounds it toward zero. For positive numbers those are the same thing, so the disagreement only appears once a minus sign does.

The two conventions compared
ExpressionFlooredTruncated
10 mod 311
250 mod 241010
100 mod 722
−9 mod 43−1
9 mod −4−31

The first three rows agree. The last two are the same two numbers with a minus sign moved, and the two conventions give different answers to both. Under flooring the result always takes the sign of the divisor, which is the behaviour clock arithmetic needs: three hours before 12 o'clock should be 9, not −3.

Frequently asked questions

What does mod mean?

It is what is left over after division. 10 mod 3 is 1, because 3 goes into 10 three times with 1 remaining. Formally, a mod n = r where a = qn + r for some whole number q.

How do I calculate a modulo by hand?

Divide, round the quotient down, multiply back, then subtract. For 250 mod 24: 250 ÷ 24 is 10.42, which floors to 10; 10 × 24 is 240; and 250 − 240 leaves 10.

What is −9 mod 4?

Three, under the convention this calculator leads with. The quotient floors to −3, and −9 − (4 × −3) = 3. Many programming languages answer −1 instead, because they truncate the quotient toward zero rather than flooring it. Both are shown so you can see which one your tool is using.

Why do calculators disagree about negative numbers?

Because "the remainder" is genuinely ambiguous for negatives — there are two whole-number answers, one with each sign. Flooring gives a result that shares the sign of the divisor, which is what modular arithmetic wants. Truncating gives one that shares the sign of the dividend, which is what most CPUs do.

What is the difference between modulo and remainder?

For positive numbers, nothing at all. They only part company when a negative is involved, where modulo follows the divisor and the remainder follows the dividend. The remainder calculator handles the long-division framing, with a quotient beside the leftover.

What is modulo used for?

Clock arithmetic and anything that wraps: hours on a 12-hour clock are mod 12, days of the week are mod 7, and a hue on a colour wheel is mod 360. It also tests divisibility — a number is even exactly when it is 0 mod 2 — and it drives hashing, check digits and cryptography.