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 · ←→ step

What's happening

Pseudocode

    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 only in this browser — no account needed.
    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.