1. Home
  2. Computer Organization & Architecture
  3. Booth's Multiplication Algorithm

Booth's Multiplication Algorithm

Multiply signed binary numbers with only add, subtract and shift. Watch the A, Q and Q₋₁ registers change bit by bit in 3D.

Interactive 3DIntermediate12 min readCOAUpdated

Drag to rotate · Right-drag to pan · Click, then scroll to zoom · Space play · Left arrowRight arrow step

What's happening

Booth’s algorithm multiplies signed binary numbers using only add, subtract and shift. It looks at two bits at a time (Q₀ and Q₋₁) to spot where runs of 1s start and end. Press Multiply.

Pseudocode

  1. A = 0000, Q₋₁ = 0, count = 4
  2. repeat 4 times:
  3. if Q₀ Q₋₁ = 1 0: A = A − M
  4. if Q₀ Q₋₁ = 0 1: A = A + M
  5. (0 0 or 1 1: do nothing)
  6. arithmetic shift right A, Q, Q₋₁
  7. result = A:Q (8 bits)
Read this model as text · 14 steps

One run of the model above, written out step by step. Useful with a screen reader, on a slow connection, or for quick revision. The values may differ from the run on your screen.

  1. Booth’s algorithm multiplies signed binary numbers using only add, subtract and shift. It looks at two bits at a time (Q₀ and Q₋₁) to spot where runs of 1s start and end. Press Multiply.
  2. Start: A = 0000, Q = 1101 (-3), Q₋₁ = 0, M = 0111 (7). We need 4 rounds — one per bit of Q.
  3. Round 1: look at Q₀ Q₋₁ = 1 0 → the start of a run of 1s: subtract M.
  4. A = A − M: 0000 + 1001 (adding −M) = 1001.
  5. Arithmetic shift right: every bit moves one place right, the old Q₀ becomes Q₋₁, and the sign bit of A (1) is copied so the sign is kept.
  6. Round 2: look at Q₀ Q₋₁ = 0 1 → the end of a run of 1s: add M.
  7. A = A + M: 1100 + 0111 = 0011 (the carry out of the top bit is simply dropped).
  8. Arithmetic shift right: every bit moves one place right, the old Q₀ becomes Q₋₁, and the sign bit of A (0) is copied so the sign is kept.
  9. Round 3: look at Q₀ Q₋₁ = 1 0 → the start of a run of 1s: subtract M.
  10. A = A − M: 0001 + 1001 (adding −M) = 1010.
  11. Arithmetic shift right: every bit moves one place right, the old Q₀ becomes Q₋₁, and the sign bit of A (1) is copied so the sign is kept.
  12. Round 4: look at Q₀ Q₋₁ = 1 1 → do nothing (inside a run of equal bits).
  13. Arithmetic shift right: every bit moves one place right, the old Q₀ becomes Q₋₁, and the sign bit of A (1) is copied so the sign is kept.
  14. Done! The 8-bit product is A:Q = 11101011 = -21. Check: 7 × -3 = -21 ✓. Booth's algorithm handles negative numbers with no special cases.

Try this in the 3D model

  • Multiply 7 × −3 and follow the A register in each round.
  • Try 3 × 7 (Q = 0111). How many additions and subtractions happen?
  • Try −5 × −6. Is the result positive?
  • Find a Q where every round says "do nothing" (hint — 0).

Multiplication with only add and shift

On paper you multiply by writing a shifted copy of the multiplicand for every 1 in the multiplier and adding them up. Hardware can do the same with an adder and a shifter. Booth’s algorithm (Andrew Booth, 1950) improves on it in two ways:

  1. It works directly on signed (two’s complement) numbers — no special cases for negatives.
  2. A run of 1s like 0111 1100 needs only one subtraction and one addition, not one addition per 1.

The idea: runs of 1s

0111 = 8 − 1. So M × 0111 = M × 8 − M × 1: subtract M at the start of the run of 1s and add it (shifted) just after the end. Reading Q from right to left, a pair of neighbouring bits tells you where you are:

Q₀ Q₋₁ Meaning Action
0 0 inside a run of 0s nothing
1 0 a run of 1s starts A = A − M
1 1 inside a run of 1s nothing
0 1 a run of 1s ends A = A + M

After each round, arithmetic shift right the combined A, Q, Q₋₁ (copy the sign bit of A).

The registers

Register Bits Starts as
M n the multiplicand
A n 0 (the accumulator)
Q n the multiplier
Q₋₁ 1 0
count — n

Worked example: 7 × (−3)

M = 0111, −M = 1001, Q = 1101 (−3).

Round Q₀ Q₋₁ Action A Q Q₋₁
start 0000 1101 0
1 1 0 A − M → 1001, shift 1100 1110 1
2 0 1 A + M → 0011, shift 0001 1111 0
3 1 0 A − M → 1010, shift 1101 0111 1
4 1 1 nothing, shift 1110 1011 1

Result A:Q = 1110 1011 = −21 ✓

Code

def booth(m, q, n=4):
    mask = (1 << n) - 1
    A, Q, q_1 = 0, q & mask, 0
    M = m & mask
    for _ in range(n):
        pair = (Q & 1, q_1)
        if pair == (1, 0):
            A = (A - M) & mask
        elif pair == (0, 1):
            A = (A + M) & mask
        # arithmetic shift right of A:Q:Q-1
        q_1 = Q & 1
        Q = ((Q >> 1) | ((A & 1) << (n - 1))) & mask
        A = (A >> 1) | (A & (1 << (n - 1)))      # keep the sign bit
    result = (A << n) | Q
    if result & (1 << (2 * n - 1)):              # interpret as signed 2n-bit
        result -= 1 << (2 * n)
    return result

print(booth(7, -3))    # -21
print(booth(-5, -6))   # 30

Common mistakes

  • Doing a logical shift (filling with 0) instead of an arithmetic shift.
  • Forgetting to shift Q₀ into Q₋₁ and A’s lowest bit into Q.
  • Reading the result from A alone — the product is A:Q together.
  • Using M = −2ⁿ⁻¹ (e.g. −8 with 4 bits): −M doesn’t fit in n bits, so A needs one extra bit.

Complexity at a glance

Case / operationTimeWhy
n-bit multiplicationn roundsEach round is at most one add/subtract plus one shift.
Long runs of 1s in Qonly 2 add/subtract operations per run
Extra spaceA, Q and Q₋₁ registers (2n + 1 bits)

Quick check

Test yourself — pick an answer to see if you got it.

1. What does Booth's algorithm do when Q₀ Q₋₁ = 1 0?

2. What does Booth's algorithm do when Q₀ Q₋₁ = 1 1?

3. Why is the shift an arithmetic shift right?

4. Where is the final product stored?

Saved in this browser.
Spotted a mistake or a bug in the 3D model?

Report a mistake

in Booth's Multiplication Algorithm. Thank you — every report makes the lesson better for the next reader.

We'll also include a link to the step of the 3D model you're on and your browser type, so we can reproduce it.