Modulo Calculator

Find the remainder and quotient when dividing two numbers.

Result

3.00
-4

How it is calculated

The quotient is the floored division q = floor(a / b), and the remainder is r = a − q × b, where a is the dividend and b the divisor. Because the quotient is rounded down (toward negative infinity), not toward zero, the remainder always takes the sign of the divisor: it is between 0 and b for a positive divisor, and between b and 0 for a negative one.

Decimals are accepted and handled exactly, so 17.5 mod 5 gives quotient 3 and remainder 2.50, and 0.3 mod 0.1 gives quotient 3 and remainder 0.00. The quotient is shown as a whole number and the remainder with two decimals. A divisor of 0 gives no result.

Worked example

Let a = -17 and b = 5. a / b = -3.4, and floor(-3.4) = -4, so the quotient is -4. The remainder is r = -17 − (-4 × 5) = -17 + 20 = 3.00. Check: -4 × 5 + 3 = -17. A truncating calculator would give -3 and -2 instead, but here the remainder stays non-negative for a positive divisor.

Try this example →

Common mistakes

  • Expecting −17 mod 5 to be −2, as in C, Java or JavaScript's % operator: this tool floors the quotient, so the answer is 3 (Python-style modulo).
  • Reading the quotient of a negative division as truncated: −17 ÷ 5 is shown as −4, not −3.
  • Entering a decimal dividend and assuming it is rounded first: the decimal part stays in the remainder (17.5 mod 5 = 2.50).
  • Using it for a clock or array wrap with a negative offset and subtracting the divisor by hand: with a positive divisor the result is already in the 0 to b range.

About this calculator

This tool computes the quotient and remainder when one number is divided by another — the modulo operation (a mod b) returns just the remainder, the amount left over after dividing a by b as many whole times as possible. For example, 17 mod 5 is 2, because 5 fits into 17 three whole times with 2 left over.

It is used by programmers implementing logic like wrapping a value around a fixed range (clock arithmetic, array indexing, cycling through a list), checking whether one number evenly divides another (a mod b = 0), or distributing items evenly into groups with a leftover. Students also use it to check long-division-style remainder problems in arithmetic and number theory coursework.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    The sign of the remainder is where programming languages disagree. This tool floors the quotient, so negative 17 mod 5 gives 3, the way Python does it. JavaScript, C and Java return negative 2 for the same pair, because they truncate toward zero. If you are porting an index wraparound or a clock calculation, check which rule your language uses. Which language or problem are you checking against?

Popular calculators

All Calculators