ARITHMETIC WORKSHEETS

Checking quotient and remainder conventions for negative integers

Dividing negative 7 by 3 gives different remainders depending on how the quotient is rounded. Floor division gives a quotient of -3 and a remainder of 2, and truncation gives -2 and -1.

The division equation

Integer division writes a dividend as divisor × quotient + remainder. For -7 divided by 3, the real quotient is about -2.333. The quotient has to be a whole number near that value, and the remainder is whatever is left over so the equation holds. There are two natural whole numbers to pick: -3, which rounds down, and -2, which rounds toward zero. The choice sets the remainder, so the pair (quotient, remainder) is not unique until a rule is stated. The basic calculator gives -7 ÷ 3 as about -2.333, which sits between those two integers.

The floor convention

Floor division rounds the quotient down, toward negative infinity. For -7 ÷ 3, the floor of -2.333 is -3. Then 3 × (-3) = -9, and the remainder is -7 - (-9) = 2. The equation reads -7 = 3 × (-3) + 2. The worked cases check it: the product 3 × (-3) = -9, and -9 + 2 = -7. With a positive divisor, floor division always produces a remainder from 0 up to one less than the divisor. That is the property mathematicians usually want, since remainders then land in a fixed range.

The truncation convention

Truncation drops the fractional part and rounds toward zero. The truncated quotient of -2.333 is -2. Then 3 × (-2) = -6, and the remainder is -7 - (-6) = -1. The equation reads -7 = 3 × (-2) + (-1). The remainder has the same sign as the dividend. In the last worked case, -6 + (-1) = -7. Both conventions satisfy the same equation, and both are valid, but they give different remainders: 2 under floor and -1 under truncation.

Both pass the same check

The reconstruction test is the product of divisor and quotient plus the remainder. Floor: 3 × (-3) + 2 = -9 + 2 = -7. Truncation: 3 × (-2) + (-1) = -6 - 1 = -7. Because both give the dividend, neither is an arithmetic mistake. The check cannot tell you which convention a system uses. It only tells you that the quotient and remainder are consistent with each other. Checking which convention was used needs a look at the sign of the remainder or at a stated rule. A useful habit is to compute both remainders when a result is going to another system, and to record the one that system expects. For a positive divisor, the floor remainder is always at least 0, while the truncated remainder is 0 or has the sign of the dividend. If the dividend is positive, the two conventions agree completely, which is why the difference only surfaces with negative inputs.

A negative divisor

The rules extend to negative divisors. For 7 ÷ (-3), the real quotient is -2.333. With floor, the quotient is -3 and the remainder is 7 - (-3)(-3) = 7 - 9 = -2, so the remainder takes the sign of the divisor. With truncation, the quotient is -2 and the remainder is 7 - (-3)(-2) = 7 - 6 = 1, which takes the sign of the dividend. In both cases the equation holds: (-3)(-3) + (-2) = 7 and (-3)(-2) + 1 = 7. A third rule, the Euclidean convention, always gives a nonnegative remainder, so it would use -2 and 1 here. The Euclidean rule keeps the remainder between 0 and the absolute value of the divisor minus one for every sign combination. For -7 divided by -3 it gives a quotient of 3 and a remainder of 2, since (-3) × 3 + 2 = -9 + 2 = -7. This rule is popular in number theory because a remainder in a fixed nonnegative range makes congruence classes easy to state. It matches floor whenever the divisor is positive.

What programming languages do

Languages differ. Python's // and % operators follow the floor convention, so -7 % 3 is 2. JavaScript's % operator and the % operator in C since the C99 standard follow truncation, so -7 % 3 is -1. Some languages offer both a remainder and a modulo function. Because the behavior is documented per language, check the documentation before moving a calculation between systems. This worksheet does not claim that one convention is universal. Its purpose is to show that the pair depends on a rule you need to name.

Naming the convention in practice

When exporting remainders to a spreadsheet, a database or another program, state which rule produced them. Hash functions, calendar arithmetic and circular buffers often assume a nonnegative remainder. Applying a truncating remainder to a negative index can produce a negative position and an out-of-range error. A common fix is to add the divisor and take the remainder again, which turns the truncated result -1 into 2 for a divisor of 3. Naming the rule beside the numbers prevents silent differences. Calendar and clock arithmetic show why the choice matters. Counting 7 hours back from 3 o'clock on a 12-hour dial lands on 8, and in remainder terms, (3 - 7) mod 12 = -4 under truncation but 8 under floor. Only the floor result corresponds to a position on the dial. Applications that wrap around, such as ring buffers and day-of-week calculations, almost always want the nonnegative result.

A second dividend worked in full

Take -17 divided by 5. The real quotient is -3.4. Floor gives -4, and the remainder is -17 - 5 × (-4) = -17 + 20 = 3. Truncation gives -3, and the remainder is -17 - 5 × (-3) = -17 + 15 = -2. Both reconstruct: 5 × (-4) + 3 = -17 and 5 × (-3) + (-2) = -17. The floor remainder 3 is in the range 0 to 4, while the truncated remainder -2 is in the range -4 to 0. Comparing the two remainders, they always differ by exactly the divisor when the division is not exact: 3 - (-2) = 5. When the division is exact, such as -15 divided by 5, both conventions agree on a quotient of -3 and a remainder of 0.

Remainders using the basic calculator

The examples use small whole numbers and show the arithmetic with the basic calculator. They do not use a dedicated modulo tool. The calculator's division gives a decimal result, and the integer quotient and remainder are worked out by the reconstruction steps. The discussion covers the floor, truncation and Euclidean conventions at an introductory level. Other rules, such as rounding to the nearest integer, exist but are less common for remainders. Results from the reconstruction steps are exact because every product and sum involves small whole numbers, and each can be repeated by hand in a few seconds.

Reproduce the checks

Floor-quotient contribution

Open the Basic calculator and enter:

First number
3
Operation
multiply
Second number
-3

Expected output:

Result

-9

The divisor times floor quotient is negative nine.

Floor reconstruction

Open the Basic calculator and enter:

First number
-9
Operation
add
Second number
2

Expected output:

Result

-7

The remainder is nonnegative in this convention.

Truncated reconstruction

Open the Basic calculator and enter:

First number
-6
Operation
add
Second number
-1

Expected output:

Result

-7

The alternative quotient has another remainder.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Related tasks