Modulo Calculator (Remainder)

Find a mod n — both the truncated and floored remainder conventions.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

This calculator computes a mod n and shows the remainder under both common conventions plus the integer quotient. It is for programmers and students who need to know exactly what a remainder will be, especially with negative numbers where languages disagree.

How it works

Two definitions are computed from the dividend (a) and divisor (n):

  • Truncated (JavaScript %, C, Java): remainder = a − n × trunc(a ÷ n). Its sign follows the dividend a.
  • Floored (Python %, mathematical “mod n”): remainder = ((a % n) + n) % n, always in the range 0 to |n|. Its sign follows the divisor n.

The quotient shown is the truncated integer quotient, trunc(a ÷ n). The two remainders are identical whenever both numbers share a sign; they differ only when exactly one is negative. Division by zero is reported as undefined.

Example

With a = -17 and n = 5:

  • Truncated: -17 − 5 × (-3) = -17 + 15 = -2
  • Floored: ((-17 % 5) + 5) % 5 = (-2 + 5) % 5 = 3
  • Quotient (truncated): -3
a mod nTruncatedFloored
17 mod 522
-17 mod 5-23
17 mod -52-3

All arithmetic happens locally in your browser, so the numbers you enter never leave your device.

Ad placeholder (rectangle)