Boneyard Tools

Modulo Calculator (Remainder and Mod)

Enter a dividend and a divisor to get the remainder, the floored modulo, and the integer quotient. Negative values are handled correctly, so you can see exactly how the two conventions differ.

How to compute a modulo

  1. Enter the dividend (the number being divided).
  2. Enter the divisor (the number you divide by).
  3. Read the remainder, the floored modulo, and the quotient.

Examples

17 mod 5

dividend 17, divisor 5
remainder 2, modulo 2, quotient 3

Negative dividend

dividend -7, divisor 3
remainder -1, modulo 2, quotient -2

Frequently asked questions

What is the difference between remainder and modulo?

The remainder follows the dividend's sign, the way the % operator works in most programming languages, so -7 % 3 is -1. The floored modulo follows the divisor's sign, so the same numbers give 2. They match whenever both numbers share a sign.

How does this calculator handle negative numbers?

The remainder is computed as dividend % divisor (truncated division), and the modulo as ((dividend % divisor) + divisor) % divisor, which stays non-negative for a positive divisor.

How is the quotient defined?

The quotient uses truncated division, Math.trunc(dividend / divisor), which rounds toward zero. So -7 divided by 3 gives a quotient of -2.

Why can the divisor not be zero?

Division and the modulo operation are undefined when the divisor is zero, so the calculator rejects it.

Do the dividend and divisor have to be whole numbers?

No. The calculator accepts decimals, and the JavaScript % operator extends naturally to them, for example 5.5 % 2 is 1.5.

Related tools