Skip to content
OddsockLocal
Local

Modulo2

Remainder
-1
Truncated quotient
-2
Modulo: 2Runs in this browser. Nothing is uploaded.

Ready

How to use

  1. Enter the dividend. Negatives are allowed.
  2. Enter a non-zero divisor.
  3. Read the truncated quotient and the remainder together. Their equation uses the remainder's sign.
  4. Read Modulo when you need a leftover that is never negative.

What is Modulo?

Dividing −7 by 3 does not have one leftover that every language agrees on. Truncating the quotient toward zero gives −2, because −2 × 3 is −6, and −7 − (−6) is −1. That −1 is the remainder: the sign follows the dividend. The modulo on this page is the non-negative residue, folded into the range from 0 up to one less than the absolute value of the divisor. For −7 and 3 that residue is 2, because −7 = −3 × 3 + 2.

Read more

Both stories are printed. Modulo 2, remainder −1, truncated quotient −2. They satisfy dividend = quotient × divisor + remainder with the truncated quotient. The modulo instead satisfies a non-negative leftover, which is what you want for clock positions, array indexes, and the day of a cycle when the step went backwards.

The divisor cannot be 0. Both inputs are integers. With a positive dividend the modulo and the remainder match: 7 divided by 3 is quotient 2, remainder 1, modulo 1. The interesting case is the negative one, which is why the sample uses −7.

Use cases

  • A programmer checking why a negative index and the % operator disagree with mathematical modulo.
  • A student showing that −7 = −2 × 3 + (−1) and also −7 = −3 × 3 + 2.
  • Someone wrapping a countdown onto a 3-hour cycle and needing a result that stays 0, 1, or 2.
  • A teacher contrasting remainder (sign of the dividend) with a non-negative residue.
  • A code review confirming a truncated quotient before a hand-rolled division.

−7 divided by 3

Dividend −7. Divisor 3.

Modulo 2. Remainder −1. Truncated quotient −2.

Why use Oddsock

Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.

Related tools

Using this tool

The non-negative modulo is 2. The remainder that pairs with a quotient truncated toward zero is −1, and that quotient is −2.