G27
Self-checkedTier 1 14 min readcoa.multiplication-booth

Multiplication: shift-add and Booth

How hardware multiplies: the shift-and-add multiplier for unsigned numbers, Booth's algorithm for two's complement numbers, why it works, how many operations it needs, the radix-4 (bit-pair) version, array multipliers and the size of the product.

Why it exists

Multiplying two nn-bit numbers by the school method gives nn partial products, each a shifted copy of the multiplicand or zero, which are added together. Hardware does exactly this, but reuses one adder: in each of nn steps it adds the multiplicand if the current multiplier bit is 1 and shifts. For signed numbers a direct approach needs sign handling; Booth's algorithm treats a run of 1s in the multiplier as one subtraction and one addition, works directly on two's complement numbers, and is faster for multipliers with long runs. GATE asks for the register contents after some steps, the number of additions, the final product, and the number of steps or partial products.

Prerequisites

You need the ALU and adder of ALU design, and two's complement and arithmetic shifts from fixed-point arithmetic and signed number representation.

Precise definitions

Product size. Multiplying an mm-bit number by an nn-bit number gives a result of up to m+nm + n bits. For two nn-bit numbers the product fits in 2n2n bits (unsigned: at most (2n−1)2<22n(2^n - 1)^2 < 2^{2n}; signed: the extreme case (−2n−1)2=22n−2(-2^{n-1})^2 = 2^{2n-2} also fits).

Sequential shift-and-add multiplier (unsigned). Registers: MM (the multiplicand, nn bits), QQ (the multiplier, nn bits, later the low half of the product), AA (the accumulator, nn bits, the high half) and a carry bit CC. AA starts at 0. Repeat nn times:

  1. If Q0=1Q_0 = 1 then A←A+MA \leftarrow A + M (the carry goes to CC).
  2. Shift C,A,QC, A, Q one place right (with a 0 entering at the top).

After nn repetitions A:QA{:}Q holds the 2n2n-bit product. Time: nn steps, each an addition and a shift. The number of additions equals the number of 1s in the multiplier.

Booth's algorithm (two's complement). Registers MM, AA (starts 0), QQ (the multiplier) and one extra bit Q−1Q_{-1} (starts 0) to the right of QQ. Repeat nn times, looking at the pair (Q0,Q−1)(Q_0, Q_{-1}):

Q0Q−1Q_0 Q_{-1}MeaningAction before the shift
0 0inside a run of 0snone
1 1inside a run of 1snone
1 0start of a run of 1s (from the right)A←A−MA \leftarrow A - M
0 1end of a run of 1sA←A+MA \leftarrow A + M

then do an arithmetic shift right of A,Q,Q−1A, Q, Q_{-1} as one register (the sign bit of AA is copied). After nn repetitions A:QA{:}Q is the 2n2n-bit two's complement product.

Why it works. A two's complement multiplier is q=−qn−12n−1+∑i<n−1qi2i=∑i=0n−1(qi−1−qi) 2iq = -q_{n-1}2^{n-1} + \sum_{i<n-1} q_i 2^i = \sum_{i=0}^{n-1} (q_{i-1} - q_i)\,2^i with q−1=0q_{-1} = 0. So each bit position contributes a digit qi−1−qi∈{−1,0,+1}q_{i-1} - q_i \in \{-1, 0, +1\}, which is exactly the table above: the pair 10 gives −1-1 (subtract), 01 gives +1+1 (add), 00 and 11 give 0. A run of 1s such as 0111=23−200111 = 2^3 - 2^0 needs just one subtraction and one addition, however long the run.

Number of operations. The number of adds and subtracts equals the number of places where neighbouring bits of the multiplier (with the extra bit Q−1=0Q_{-1} = 0 to the right) differ. Best case: all 0s or all 1s (0 or 1 operations); worst case: alternating bits 0101... (about nn operations). The shift-and-add method needs as many additions as the multiplier has 1s.

A caveat. If the multiplicand is the most negative number −2n−1-2^{n-1}, then A−M=A+2n−1A - M = A + 2^{n-1} may not fit in nn bits. The adder must keep an extra bit (or the AA register needs one more bit) for the result to be right.

Radix-4 Booth (bit-pair recoding). Examine three bits (q2i+1,q2i,q2i−1)(q_{2i+1}, q_{2i}, q_{2i-1}) at a time and produce one digit in {−2,−1,0,+1,+2}\{-2, -1, 0, +1, +2\}:

q2i+1 q2i q2i−1q_{2i+1}\,q_{2i}\,q_{2i-1}000001010011100101110111
digit0+1+1+2-2-1-10

The multiplier then has only n/2n/2 digits, so there are only n/2n/2 partial products (00, ±M\pm M, ±2M\pm 2M; 2M2M is just a shift) and the multiplication takes n/2n/2 steps instead of nn.

Array multiplier. A combinational multiplier for a jj-bit by kk-bit product: j⋅kj \cdot k AND gates form all the partial-product bits and j−1j - 1 rows of kk-bit adders add them; the product has j+kj + k bits. It is fast (delay about proportional to j+kj + k) but large.

How it works

First the unsigned shift-and-add multiplier for 13×1113 \times 11. Watch A:QA{:}Q: the multiplier bits leave from the right of QQ while the product grows from the left.

Shift-and-add multiplication: 13 x 11: Start

Computed exactly, not typed

Working

M = 1101 (13), Q = 1011 (11), A = 0000, C = 0
4 repetitions

Value, format and bits (changed bits in amber)

M (multiplicand)unsigned= 13
1101
C (carry from the add)= 0
A (upper half of the product)unsigned= 0
0000
Q (multiplier, lower half)unsigned= 11
1011

Step 1

The unsigned multiplier lives in Q, the multiplicand in M, and A starts at 0. A and Q together will hold the 8-bit product. In each of the 4 repetitions the lowest bit of Q decides whether M is added to A.

1 / 10
computed by script: a simulation of the machine, one register transfer per step. Python 3.15.1, darwin arm64. python3 scripts/gen-coa-traces.py

Now Booth's algorithm for 7×(−3)7 \times (-3) with 4-bit registers. The multiplier −3=1101-3 = 1101 has bit changes at three places (reading with Q−1=0Q_{-1} = 0 on the right: 1 1 0 1 0 gives changes at the 1-0, 0-1 and 1-0 boundaries), so there are three operations: subtract, add, subtract.

Booth's algorithm: 7 x (-3): Start

Computed exactly, not typed

Working

M = 0111 (7), Q = 1101 (-3), A = 0000, Q-1 = 0
4 repetitions

Value, format and bits (changed bits in amber)

M (multiplicand)twos-complement= 7
0111
Atwos-complement= 0
0000
Q (multiplier)twos-complement= -3
1101
Q-1 (the bit shifted out last)= 0

Step 1

Booth's algorithm multiplies two's complement numbers directly, with no sign correction. Each repetition looks at the pair (Q0, Q-1): the lowest multiplier bit and the bit that was just shifted out.

1 / 10
computed by script: a simulation of the machine, one register transfer per step. Python 3.15.1, darwin arm64. python3 scripts/gen-coa-traces.py

Worked examples

EX 1Both multipliers in a program

Easy
#include <stdio.h>
 
/* unsigned shift-and-add: A:Q holds the product after n repetitions */
static unsigned shift_add(unsigned m, unsigned q, int n, int *adds) {
    unsigned a = 0, c = 0, mask = (1u << n) - 1;
    *adds = 0;
    for (int i = 0; i < n; i++) {
        if (q & 1) { unsigned t = a + m; c = t >> n; a = t & mask; (*adds)++; }
        unsigned full = ((c << (2 * n)) | (a << n) | q) >> 1;
        c = 0; a = (full >> n) & mask; q = full & mask;
    }
    return (a << n) | q;
}
 
/* Booth: A is kept as a signed int so that A - M cannot overflow even for the most negative M */
static int booth(int m, int q, int n, int *ops) {
    int a = 0, qm1 = 0;
    unsigned qq = (unsigned)q & ((1u << n) - 1);
    *ops = 0;
    for (int i = 0; i < n; i++) {
        int pair = (int)(qq & 1) * 2 + qm1;
        if (pair == 2) { a -= m; (*ops)++; }
        else if (pair == 1) { a += m; (*ops)++; }
        int newqm1 = (int)(qq & 1);
        qq = (qq >> 1) | ((unsigned)(a & 1) << (n - 1));
        a >>= 1;                                   /* arithmetic shift right */
        qm1 = newqm1;
    }
    int low = (int)qq;
    return a * (1 << n) + low;                     /* A:Q as a signed 2n-bit number */
}
 
/* radix-4 recoding of an n-bit two's complement multiplier into n/2 digits from -2 to 2 */
static void radix4(int q, int n, int *digits) {
    static const int table[8] = { 0, 1, 1, 2, -2, -1, -1, 0 };
    unsigned u = (unsigned)q & ((1u << n) - 1);
    int prev = 0;                                  /* the bit below the pair: q[i-1], 0 for the first pair */
    for (int i = 0; i < n; i += 2) {
        int triple = (int)(((u >> i) & 3) << 1) | prev;   /* (q[i+1], q[i], q[i-1]) */
        digits[i / 2] = table[triple];
        prev = (int)((u >> (i + 1)) & 1);
    }
}
 
int main(void) {
    int adds, ops;
    unsigned p1 = shift_add(13, 11, 4, &adds);
    printf("13 x 11 (unsigned) = %u with %d additions (11 = 1011 has three 1s)\n", p1, adds);
    int p2 = booth(7, -3, 4, &ops);
    printf("7 x -3 (Booth) = %d with %d add/subtract operations\n", p2, ops);
    int p3 = booth(5, 7, 4, &ops);
    printf("5 x 7 (Booth) = %d with %d operations (7 = 0111: one subtract, one add)\n", p3, ops);
    int p4 = booth(-8, -8, 4, &ops);
    printf("-8 x -8 (Booth, most negative multiplicand) = %d\n", p4);
    int bad_u = 0, bad_b = 0;
    for (unsigned m = 0; m < 64; m++)
        for (unsigned q = 0; q < 64; q++) {
            int a;
            bad_u += shift_add(m, q, 6, &a) != m * q;
        }
    for (int m = -32; m < 32; m++)
        for (int q = -32; q < 32; q++) bad_b += booth(m, q, 6, &ops) != m * q;
    printf("6-bit operands: shift-and-add wrong on %d of 4096 pairs, Booth wrong on %d of 4096 pairs\n", bad_u, bad_b);
    int d[2];
    radix4(-3, 4, d);
    printf("radix-4 digits of -3 (1101): %d %d (value %d x 1 + %d x 4)\n", d[0], d[1], d[0], d[1]);
    return 0;
}
13 x 11 (unsigned) = 143 with 3 additions (11 = 1011 has three 1s)
7 x -3 (Booth) = -21 with 3 add/subtract operations
5 x 7 (Booth) = 35 with 2 operations (7 = 0111: one subtract, one add)
-8 x -8 (Booth, most negative multiplicand) = 64
6-bit operands: shift-and-add wrong on 0 of 4096 pairs, Booth wrong on 0 of 4096 pairs
radix-4 digits of -3 (1101): 1 -1 (value 1 x 1 + -1 x 4)

Reading it. 13×11=14313 \times 11 = 143 with three additions (11 = 1011 has three 1s). Booth's 7×(−3)=−217 \times (-3) = -21 needs three operations; 5×7=355 \times 7 = 35 needs only two because 7=01117 = 0111 is a single run of 1s. −8×−8=64-8 \times -8 = 64 works because the A register in the program is a signed integer that can hold A−M=A+8A - M = A + 8. The checks cover all 4096 pairs of 6-bit operands for both algorithms. The radix-4 digits of −3-3 are +1+1 and −1-1 (the first pair gives +1×1+1 \times 1, the second −1×4-1 \times 4): 1−4=−31 - 4 = -3.

EX 2Count the operations

Easy

How many add or subtract operations does Booth's algorithm perform for the multiplier 01100110 (6)? Append the extra bit: 0110 00110\,0. Neighbouring pairs from the right: (0,0)(0,0) no change; (1,0)(1,0) change; (1,1)(1,1) no; (0,1)(0,1) change. Two operations: subtract MM at the start of the run, add MM at its end: 6=8−26 = 8 - 2. The shift-and-add multiplier needs 2 additions as well (two 1s). For the multiplier 01010101 (5): changes at all boundaries: 4 operations for Booth, but only 2 additions for shift-and-add. For 01110111 (7): 2 operations for Booth, 3 additions for shift-and-add.

EX 3A step of Booth's algorithm by hand

Medium

M=0111M = 0111 (7), Q=1101Q = 1101 (−3-3), A=0000A = 0000, Q−1=0Q_{-1} = 0. Repetition 1: Q0Q−1=10Q_0 Q_{-1} = 10, so A←A−M=0000−0111=1001A \leftarrow A - M = 0000 - 0111 = 1001; arithmetic shift of A Q Q−1A\,Q\,Q_{-1} gives A=1100A = 1100, Q=1110Q = 1110, Q−1=1Q_{-1} = 1 (the animation shows exactly this). Repetition 2: Q0Q−1=01Q_0 Q_{-1} = 01, so A←1100+0111=0011A \leftarrow 1100 + 0111 = 0011, shift: A=0001A = 0001, Q=1111Q = 1111, Q−1=0Q_{-1} = 0. Repetition 3: pair 10, A←0001−0111=1010A \leftarrow 0001 - 0111 = 1010, shift: A=1101A = 1101, Q=0111Q = 0111, Q−1=1Q_{-1} = 1. Repetition 4: pair 11, nothing, shift: A=1110A = 1110, Q=1011Q = 1011. The product is A:Q=1110 1011=−21A{:}Q = 1110\,1011 = -21.

EX 4Time and hardware

Medium

A sequential 32-bit shift-and-add multiplier takes 32 steps, each an addition and a shift; if one step takes 1 clock the multiplication takes 32 clocks and needs a 32-bit adder, a 64-bit shift register for A:QA{:}Q, and a 32-bit register for MM. Radix-4 Booth halves the number of steps to 16. An array multiplier does the whole product combinationally in a time that grows roughly in proportion to the operand width, but needs 32×32=102432 \times 32 = 1024 AND gates and 31 rows of 32-bit adders.

EX 5Radix-4 recoding

GATE level

Recode q=1101q = 1101 (−3-3) with a 0 appended on the right. Pairs from the right: (q1q0q−1)=(0 1 0)(q_1 q_0 q_{-1}) = (0\,1\,0) gives +1+1; (q3q2q1)=(1 1 0)(q_3 q_2 q_1) = (1\,1\,0) gives −1-1. The value is 1⋅40+(−1)⋅41=−31 \cdot 4^0 + (-1) \cdot 4^1 = -3. So M×q=M−4MM \times q = M - 4M: two partial products instead of four. The checking script verifies the recoding table for every multiplier of 4, 6 and 8 bits.

EX 6Size of the product

GATE level

Multiplying two 8-bit unsigned numbers: the largest product is 255×255=65025255 \times 255 = 65025, which needs 16 bits (215=32768≤65025<655362^{15} = 32768 \le 65025 < 65536). A 16-bit product register is therefore always enough. For signed 8-bit numbers the largest magnitude is (−128)2=16384=214(-128)^2 = 16384 = 2^{14}, which also fits in 16 bits. If the result is stored back in 8 bits the high half is lost, which is how integer multiplication overflows in C.

Cheat box

Cheat box

  • Product of mm-bit by nn-bit: up to m+nm + n bits. n×nn \times n fits in 2n2n bits.
  • Shift-and-add (unsigned): nn steps; add MM to AA if Q0=1Q_0 = 1; shift C:A:QC{:}A{:}Q right. Additions = number of 1s.
  • Booth: pair (Q0,Q−1)(Q_0, Q_{-1}): 10 subtract, 01 add, 00/11 nothing; then arithmetic shift right of A:Q:Q−1A{:}Q{:}Q_{-1}. nn steps.
  • Booth operations = number of changes between neighbouring multiplier bits (with Q−1=0Q_{-1} = 0). Run of 1s costs 2 whatever its length.
  • Most negative multiplicand needs a one-bit-wider add.
  • Radix-4: digits −2..+2-2..+2 from triples; n/2n/2 partial products.
  • Array multiplier: j⋅kj \cdot k AND gates, j−1j - 1 adders of kk bits.

Traps and GATE patterns

Connections

Everything here uses the adder of the ALU and the flags of fixed-point arithmetic. The same shift-and-subtract idea with the roles reversed gives division. In the datapath the multiplier is a state machine (counter plus control) around the ALU. Multiplication time is one of the terms in the performance equations.

PYQs

4 previous year questions from your book. I re-solved each one myself (4 by running or simulating, 0 by reasoning only); the book's key is shown next to my answer. All PYQs

GATE 2025 · Set 2 · NAT · 1 markQ6 · page 153 of the book
The following two signed 2's complement numbers
(multiplicand M and multiplier Q) are being
multiplied using Booth's algorithm:

M: 1100110111101101

Q: 1010010010101010

The total number of addition and subtraction
operations to be performed is __________.

DIGITAL LOGIC
GATE 2008 · MCQ · 1 markQ28 · page 156 of the book
The two numbers given below are multiplied
using the Booth's algorithm.

Multiplicand: 0101 1010 1110 1110

Multiplier: 0111 0111 1011 1101

How many additions/Subtractions are required for
the multiplication of the above two numbers?
  • (a)6
  • (b)8
  • (c)10
  • (d)12
GATE 2006 · MCQ · 1 markQ32 · page 156 of the book
When multiplicand Y is multiplied by multiplier X =
xn-1 xn-2 ... x0 using bit-pair recoding in Booth's
algorithm, partial products are generated according to
the following table.

DIGITAL LOGIC

The partial products for rows 5 and 8 are?
  • (a)2Y and Y
  • (b)-2Y and 2Y
  • (c)-2Y and 0
  • (d)0 and Y
GATE 2005 · MCQ · 1 markQ33 · page 157 of the book
Using Booth's Algorithm for multiplication, the
multiplier -57 will be recoded as
  • (a)0 -1 0 0 1 0 0 -1
  • (b)1 1 0 0 0 1 1 1
  • (c)0 -1 0 0 1 0 0 0
  • (d)0 1 0 0 -1 0 0 1

Self-check

Question 1

How many add or subtract operations does Booth's algorithm perform for the 8-bit multiplier 0111 1100?

Show answer

The multiplier has one run of 1s (bits 2 to 6): one subtraction at the start (bit 2) and one addition at the end (bit 7): 2 operations.

Question 2

How many bits does the product register need for 16-bit by 16-bit multiplication?

Show answer

2×16=322 \times 16 = 32 bits.

Question 3

The multiplier is −1-1 in 4 bits (1111). How many operations does Booth's algorithm use and what is M×(−1)M \times (-1)?

Show answer

One subtraction at the first step (pair 10), then pairs 11, 11, 11 do nothing: 1 operation. The result is 0−M=−M0 - M = -M.

Question 4

How many partial products does radix-4 Booth need for a 16-bit multiplier?

Show answer

8 (one per bit pair).

Revision card

One-screen revision

  • Shift-and-add: nn steps, add if Q0=1Q_0 = 1, shift right; adds = number of 1s. Product 2n2n bits.
  • Booth: 10 subtract, 01 add, else nothing; arithmetic shift of A,Q,Q−1A, Q, Q_{-1}; operations = bit changes.
  • q=∑(qi−1−qi)2iq = \sum (q_{i-1} - q_i)2^i. Radix-4: digits −2-2 to 22, n/2n/2 partial products.
  • Most negative MM needs one extra bit. Array multiplier: jkjk ANDs, j−1j - 1 adders.

References

  • ·Hennessy and Patterson, Computer Organization and Design, Chapter 3 Arithmetic for Computers (multiplication)
  • ·Morris Mano, Computer System Architecture, 3rd ed., Chapter 10 Computer Arithmetic (multiplication algorithms, Booth, array multiplier)
  • ·Hamacher, Vranesic, Zaky, Computer Organization, 5th ed., Chapter 6 Arithmetic (multiplication of positive and signed numbers, fast multiplication)

Verification

Shift-and-add is checked for every operand pair of 4, 5 and 6 bits; Booth's algorithm for every signed pair of 4, 5 and 6 bits (including the most negative multiplicand, which needs a one-bit-wider add), the number of operations (equal to the number of changes between neighbouring multiplier bits), the identity q = sum of (q[i-1] - q[i]) 2^i, the radix-4 recoding for every multiplier of 4, 6 and 8 bits, and the array-multiplier structure, all in scripts/enum-checks/coa_alu.py. The animations are re-run independently in tests/coa-traces.test.ts and the C program on the page (npm run verify:c) checks both multipliers on all 6-bit pairs. Register names and the order of the steps differ slightly between textbooks (for example the carry bit or the name of the extra bit); the text states the version used. Textbook chapter titles are from memory. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand (long C programs were not re-read line by line: they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose). No defect found. Status raised to self-checked; verified needs a textbook or human check.

last verified: never