---
title: "Restoring division of 31 by 13"
subject: "Computer Organization and Architecture"
chapter: 5
key: "semester_5/computer_organization_and_architecture:restoring-31-13"
source: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/restoring-31-13
site: BCT Engineering
---

# Restoring division of 31 by 13

Computer Organization and Architecture · Chapter 5: Computer Arithmetic

- Asked in: 2079 Baisakh, 8 marks
- Video: [Restoring Division Algorithm for Unsigned Integer](https://www.youtube.com/watch?v=PzV6gYpVLuc) — TutorialsPoint
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/restoring-31-13
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_organization_and_architecture/chapter-5

## Question

Explain the restoring division algorithm. Use this algorithm to divide 31 (dividend) by 13 (divisor).

## Short answer

In restoring division, shift A,Q left, subtract divisor, restore by adding back if A is negative, and set Q0 accordingly. Dividing 31 by 13 gives quotient 2 (00010) and remainder 5 (000101).

## Answer

#### Restoring division algorithm

1. Load A = 0, Q = dividend, M = divisor, SC = n.
2. Shift A and Q left by one bit (the MSB of Q goes into the LSB of A).
3. A = A − M.
4. If A < 0 (sign bit 1): set Q0 = 0 and **restore** A by adding M back (A = A + M).
   If A ≥ 0: set Q0 = 1.
5. SC = SC − 1. If SC ≠ 0 repeat from step 2.
6. At the end Q holds the quotient and A holds the remainder.

#### 31 ÷ 13

Dividend = 31 = 11111 (Q), divisor M = 13 = 001101 (n+1 = 6 bits), A = 0, n = 5.

```text
Step  Action                    A       Q
-     Initial                   000000  11111
1     Shift left A,Q            000001  11110
      A = A - M (1 - 13 = -12)  110100  11110
      A<0: Q0=0, restore A      000001  11110
2     Shift left A,Q            000011  11100
      A = A - M (3 - 13 = -10)  110110  11100
      A<0: Q0=0, restore A      000011  11100
3     Shift left A,Q            000111  11000
      A = A - M (7 - 13 = -6)   111010  11000
      A<0: Q0=0, restore A      000111  11000
4     Shift left A,Q            001111  10000
      A = A - M (15 - 13 = 2)   000010  10000
      A>=0: Q0=1                000010  10001
5     Shift left A,Q            000101  00010
      A = A - M (5 - 13 = -8)   111000  00010
      A<0: Q0=0, restore A      000101  00010
```

**Answer: 31 ÷ 13: quotient = 2 (00010), remainder = 5 (000101)**

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why is M written with 6 bits (001101) for 31 / 13?
   A. Because 13 needs 6 bits
   B. Register A and the adder are n+1 = 6 bits
   C. To store the quotient
   D. To allow a negative divisor
   Answer: B. The dividend 31 has n = 5 bits so A and M are n+1 = 6 bits. (Key point: Divisor width)

2. In step 1 A = 1 - 13 = -12 is negative. What happens?
   A. Q0 = 1 and A stays -12
   B. Q0 = 0 and A stays -12
   C. Q0 = 0 and A is restored by adding M
   D. Q0 = 1 and M is subtracted again
   Answer: C. A < 0 means the divisor did not fit; restore A and set Q0 = 0. (Key point: Restore)

3. What is the quotient of 31 / 13?
   A. 2 (00010)
   B. 3 (00011)
   C. 1 (00001)
   D. 5 (00101)
   Answer: A. Only step 4 had A >= 0 (15 - 13 = 2), setting Q0 = 1, giving 00010 = 2. (Key point: Quotient)

4. What is the remainder, and the check?
   A. 2, since 13 x 5 + 2 = 67
   B. 5, since 13 x 2 + 5 = 31
   C. 5, since 13 x 2 + 5 = 26
   D. 0, since 13 x 2 = 26
   Answer: B. A ends as 000101 = 5; 26 + 5 = 31. (Key point: Remainder)

## Related in Computer Organization and Architecture

- [Restoring division algorithm and hardware](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Arestoring-division) — Computer Organization and Architecture, chapter 5, asked 2×
- [Signed division and non-restoring division](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Anonrestoring-division) — Computer Organization and Architecture, chapter 5
- [Non-restoring division of 10 by 5](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Anonrestoring-10-5) — Computer Organization and Architecture, chapter 5
- [Non-restoring division with flowchart](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Anonrestoring-explain) — Computer Organization and Architecture, chapter 5, asked 3×
- [Restoring division of 10 by 3](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Arestoring-10-3) — Computer Organization and Architecture, chapter 5
- [Restoring vs non-restoring division](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Arestoring-vs-nonrestoring) — Computer Organization and Architecture, chapter 5, asked 5×
