Modulo Calculator

Enter a dividend and a divisor. You get the remainder and the quotient under all three conventions, so a negative number gives the answer your language expects.

How it works

Dividing a by n gives a whole-number quotient q and a remainder r, with a = n × q + r. For positive numbers there is only one answer: 17 mod 5 is 2.

With a negative number, languages disagree on which way to round the quotient. C, Java and JavaScript round toward zero, so the remainder takes the sign of a. Python and Excel round down, so the result takes the sign of n. The Euclidean version always gives a result of 0 or more.

The calculator shows all three with their quotients and the check a = n × q + r. It uses exact whole-number arithmetic, so numbers up to 10,000 digits work. Everything runs on this page.

How to use it

  1. 1 Type the dividend, the number being divided.
  2. 2 Type the divisor, the number to divide by.
  3. 3 Read the row that matches your language or spreadsheet.
  4. 4 Check the quotient and the a = n × q + r line under each answer.

Good to know

  • In JavaScript, (-7 % 3 + 3) % 3 turns the remainder into Python-style modulo. It gives 2.
  • For clock arithmetic, use modulo: 10 hours after 17:00 is (17 + 10) mod 24, which is 3, or 03:00.
  • For array indexes that wrap around backwards, use the Euclidean or Python-style result, which is never negative for a positive length.
  • Commas and spaces in the numbers are ignored.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Remainder or modulo: why -7 mod 3 has two answers

The modulo operation gives what is left after a whole-number division. 17 divided by 5 is 3 with 2 left over, so 17 mod 5 is 2. The four numbers are always tied together by one rule: the dividend equals the divisor times the quotient, plus the remainder. Here, 17 = 5 × 3 + 2. Modulo is behind clock time, days of the week, checksums, hashing and every "every nth item" rule in a program.

With positive numbers, there is only one sensible answer. With a negative number, there are two. Take -7 divided by 3. The exact answer is -2.33. Round the quotient toward zero and you get -2, so the remainder is -7 minus 3 × -2, which is -1. Round the quotient down and you get -3, so the remainder is -7 minus 3 × -3, which is 2. Both satisfy the rule. They just pick a different quotient.

Programming languages split along that line. C, C++, Java, C#, JavaScript, Go, Rust and Swift round toward zero, so their % operator gives -1, and the result has the sign of the dividend. Python, Ruby, and the MOD function in Excel and Google Sheets round down, so they give 2, and the result has the sign of the divisor. A third convention, Euclidean modulo, always gives a result of 0 or more, whatever the signs. Rust offers it as rem_euclid. Java has Math.floorMod for the Python behaviour.

The difference causes real bugs. Code that wraps an index backwards through a list with (i - 1) % length works in Python and fails in JavaScript, where it gives -1 at the start of the list. Code that tests whether a number is odd with n % 2 == 1 misses negative odd numbers in C and JavaScript, where -3 % 2 is -1. This calculator shows the three conventions side by side, so you can see which one your code is using and what the other would give.

Some limits are worth knowing. The calculator takes whole numbers only, with up to 10,000 digits each, and works them out exactly. It does not take decimals, so it does not reproduce the fractional remainders that JavaScript and Python give for numbers such as 5.5 % 2. The divisor cannot be 0. The language names describe each language's built-in % operator or MOD function; a library may define its own.

Frequently asked questions

What is -7 mod 3?

It depends on the convention. In C, Java and JavaScript, -7 % 3 is -1. In Python and in Excel MOD, it is 2. The Euclidean modulo is also 2. All three satisfy -7 = 3 × q + r; they just pick a different q.

Is a remainder the same as a modulo?

For positive numbers, yes. With negatives, "remainder" usually means the truncated result, which keeps the sign of the dividend, and "modulo" means the floored or Euclidean result, which does not go negative for a positive divisor.

Can I use decimals?

No. This calculator works on whole numbers, where the answers are exact. Most languages also allow a remainder of decimals, such as 5.5 % 2 = 1.5, but that is outside what this tool does.

Why can the divisor not be 0?

Nothing divides by zero, so there is no quotient and no remainder. Most languages raise an error or return NaN in this case.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.