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.