Advertisement

Floor division calculator

Enter two safe integers with a non-zero divisor. Floor division rounds downward, so -7 divided by 3 gives quotient -3 rather than -2.

Calculator

Floor quotient
-3
Remainder
2
Division identity
-7 = (3) × (-3) + (2)

Advertisement

How this calculator works

Compute the exact integer quotient, adjusting it down by one when truncation toward zero would be too high. The remainder then follows from dividend minus divisor times quotient. With this convention, a non-zero remainder has the divisor's sign. This differs from truncating integer division for opposite-signed inputs.

Formula

q = floor(a/b); r = a - bq. If b > 0, 0 <= r < b. If b < 0, b < r <= 0.

Worked example

-7 divided by 3 has q = -3 and r = 2 because -7 = 3 × (-3) + 2. For 7 divided by -3, q = -3 and r = -2.

Advertisement

Frequently asked questions

Why is -7 divided by 3 rounded to -3?

The floor is the greatest integer no larger than -2.333..., which is -3.

Can a remainder be negative?

Yes when the divisor is negative. This is the floor-division convention stated here.

Why are the integer outputs shown as text?

Exact integer text preserves the quotient-remainder identity without display rounding or grouping ambiguity.

Sources

Advertisement