Restoring Division Calculator
Perform unsigned binary division using the restoring division algorithm. Follow accumulator A, quotient register Q, divisor M, left shifts, subtraction tests, restoration steps, quotient-bit decisions and the final remainder.
| Cycle | A,Q After Left Shift | A – M | Test | Action | Quotient Bit | Final A | Final Q |
|---|---|---|---|---|---|---|---|
| Enter values and calculate to view the division cycles. | |||||||
What Is Restoring Division?
Restoring division is a sequential binary division algorithm commonly used to explain how unsigned division can be implemented with registers, shifts, subtraction and conditional restoration.
The dividend begins in register Q, the divisor is stored in M, and accumulator A starts at zero. During each cycle, the combined A and Q registers are shifted left and the divisor is subtracted from A.
If the subtraction produces a negative accumulator, A is restored by adding M back and the new quotient bit becomes 0. If A remains non-negative, the subtraction is kept and the quotient bit becomes 1.
Registers Used in Restoring Division
A — Accumulator
A begins at zero and stores the partial remainder during each division cycle.
Q — Dividend / Quotient
Q initially contains the dividend. As the algorithm runs, its low-order positions are replaced with calculated quotient bits.
M — Divisor
M holds the divisor throughout the entire restoring division process.
Cycle Counter
The standard algorithm performs one division cycle for each dividend bit.
Restoring Division Algorithm Steps
A = 0
Q = Dividend
M = Divisor
For each bit:
1. Shift the combined A,Q register left.
2. Calculate A = A – M.
3. Check the sign of A.
If A is negative:
Q0 = 0
A = A + M
This restores the previous non-negative partial remainder.
If A is non-negative:
Q0 = 1
Keep the new A value.
Repeat for n cycles.
Final:
Q = Quotient
A = Remainder
Why Is It Called Restoring Division?
The name comes from what happens after an unsuccessful subtraction. When subtracting divisor M makes accumulator A negative, that subtraction cannot be retained for the current quotient position.
The algorithm therefore adds M back to A, restoring the accumulator to its value before the failed subtraction.
A – M
If result is negative:
A = (A – M) + M
Therefore:
A returns to the shifted pre-subtraction value.
How the Quotient Bit Is Selected
| Result of A – M | Q0 | Accumulator Action |
|---|---|---|
| Negative | 0 | Restore A by adding M |
| Zero | 1 | Keep A = 0 |
| Positive | 1 | Keep new A |
Worked Example: 13 ÷ 3
Q = 1101 = 13
4-bit divisor:
M = 0011 = 3
Decimal division:
13 ÷ 3
Quotient:
4 = 0100
Remainder:
1 = 0001
Verification:
3 × 4 + 1 = 13
Worked Example: 15 ÷ 3
1111 = 15
Divisor:
0011 = 3
Quotient:
0101 = 5
Remainder:
0000 = 0
Verification:
3 × 5 + 0 = 15
Worked Example: 11 ÷ 2
1011 = 11
Divisor:
0010 = 2
Quotient:
0101 = 5
Remainder:
0001 = 1
Verification:
2 × 5 + 1 = 11
Binary Restoring Division Examples
| Dividend | Divisor | Quotient | Remainder | Decimal Check |
|---|---|---|---|---|
| 1000 | 0010 | 0100 | 0000 | 8 ÷ 2 = 4 |
| 1001 | 0010 | 0100 | 0001 | 9 = 2×4 + 1 |
| 1011 | 0010 | 0101 | 0001 | 11 = 2×5 + 1 |
| 1101 | 0011 | 0100 | 0001 | 13 = 3×4 + 1 |
| 1111 | 0011 | 0101 | 0000 | 15 = 3×5 |
What If the Dividend Is Smaller Than the Divisor?
The restoring algorithm still works normally. If the unsigned dividend is smaller than the divisor, no successful divisor subtraction produces a quotient contribution large enough to make the quotient nonzero.
0011 = 3
Divisor:
0101 = 5
Result:
Quotient = 0000
Remainder = 0011
3 = 5 × 0 + 3
Restoring Division Remainder Rule
For valid unsigned integer division with a nonzero divisor, the final remainder must always be smaller than the divisor.
with:
0 ≤ Remainder < Divisor
Restoring Division vs Ordinary Binary Division
| Feature | Ordinary Binary Division | Restoring Division |
|---|---|---|
| Primary goal | Find quotient and remainder | Simulate register-level division |
| Accumulator | Usually not exposed | A register explicitly tracked |
| Trial subtraction | Conceptual | Performed every cycle |
| Negative trial | Skip subtraction | Subtract, then restore A |
| Quotient generation | Long-division style | One quotient bit per cycle |
| Best use | General conversion/math | Computer arithmetic study |
Why Study Restoring Division?
Computer Architecture
The algorithm demonstrates how division can be decomposed into shifts, subtraction, tests and register updates.
Digital Arithmetic
It provides a clear model for understanding sequential unsigned division hardware.
Register Operations
Students can see how accumulator and quotient registers change during every cycle.
Algorithm Comparison
Restoring division provides a useful baseline for studying alternative hardware division algorithms.
Important Restoring Division Notes
The divisor cannot be zero.
A standard n-bit calculation runs for n cycles.
The quotient is stored in Q and the final partial remainder is stored in A.
Whenever the trial subtraction makes A negative, the algorithm restores A by adding M back and places 0 in the current quotient position.
A valid final result satisfies:
Dividend = Divisor × Quotient + Remainder
and the final remainder must be smaller than the divisor.