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 -bit numbers by the school method gives 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 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 -bit number by an -bit number gives a result of up to bits. For two -bit numbers the product fits in bits (unsigned: at most ; signed: the extreme case also fits).
Sequential shift-and-add multiplier (unsigned). Registers: (the multiplicand, bits), (the multiplier, bits, later the low half of the product), (the accumulator, bits, the high half) and a carry bit . starts at 0. Repeat times:
- If then (the carry goes to ).
- Shift one place right (with a 0 entering at the top).
After repetitions holds the -bit product. Time: 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 , (starts 0), (the multiplier) and one extra bit (starts 0) to the right of . Repeat times, looking at the pair :
| Meaning | Action before the shift | |
|---|---|---|
| 0 0 | inside a run of 0s | none |
| 1 1 | inside a run of 1s | none |
| 1 0 | start of a run of 1s (from the right) | |
| 0 1 | end of a run of 1s |
then do an arithmetic shift right of as one register (the sign bit of is copied). After repetitions is the -bit two's complement product.
Why it works. A two's complement multiplier is with . So each bit position contributes a digit , which is exactly the table above: the pair 10 gives (subtract), 01 gives (add), 00 and 11 give 0. A run of 1s such as 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 to the right) differ. Best case: all 0s or all 1s (0 or 1 operations); worst case: alternating bits 0101... (about 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 , then may not fit in bits. The adder must keep an extra bit (or the register needs one more bit) for the result to be right.
Radix-4 Booth (bit-pair recoding). Examine three bits at a time and produce one digit in :
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| digit | 0 | +1 | +1 | +2 | -2 | -1 | -1 | 0 |
The multiplier then has only digits, so there are only partial products (, , ; is just a shift) and the multiplication takes steps instead of .
Array multiplier. A combinational multiplier for a -bit by -bit product: AND gates form all the partial-product bits and rows of -bit adders add them; the product has bits. It is fast (delay about proportional to ) but large.
How it works
First the unsigned shift-and-add multiplier for . Watch : the multiplier bits leave from the right of while the product grows from the left.
Shift-and-add multiplication: 13 x 11: Start
Computed exactly, not typedWorking
M = 1101 (13), Q = 1011 (11), A = 0000, C = 0 4 repetitions
Value, format and bits (changed bits in amber)
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.
Now Booth's algorithm for with 4-bit registers. The multiplier has bit changes at three places (reading with 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 typedWorking
M = 0111 (7), Q = 1101 (-3), A = 0000, Q-1 = 0 4 repetitions
Value, format and bits (changed bits in amber)
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.
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. with three additions (11 = 1011 has three 1s). Booth's needs three operations; needs only two because is a single run of 1s. works because the A register in the program is a signed integer that can hold . The checks cover all 4096 pairs of 6-bit operands for both algorithms. The radix-4 digits of are and (the first pair gives , the second ): .
EX 2Count the operations
EasyHow many add or subtract operations does Booth's algorithm perform for the multiplier (6)? Append the extra bit: . Neighbouring pairs from the right: no change; change; no; change. Two operations: subtract at the start of the run, add at its end: . The shift-and-add multiplier needs 2 additions as well (two 1s). For the multiplier (5): changes at all boundaries: 4 operations for Booth, but only 2 additions for shift-and-add. For (7): 2 operations for Booth, 3 additions for shift-and-add.
EX 3A step of Booth's algorithm by hand
Medium(7), (), , . Repetition 1: , so ; arithmetic shift of gives , , (the animation shows exactly this). Repetition 2: , so , shift: , , . Repetition 3: pair 10, , shift: , , . Repetition 4: pair 11, nothing, shift: , . The product is .
EX 4Time and hardware
MediumA 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 , and a 32-bit register for . 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 AND gates and 31 rows of 32-bit adders.
EX 5Radix-4 recoding
GATE levelRecode () with a 0 appended on the right. Pairs from the right: gives ; gives . The value is . So : 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 levelMultiplying two 8-bit unsigned numbers: the largest product is , which needs 16 bits (). A 16-bit product register is therefore always enough. For signed 8-bit numbers the largest magnitude is , 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 -bit by -bit: up to bits. fits in bits.
- Shift-and-add (unsigned): steps; add to if ; shift right. Additions = number of 1s.
- Booth: pair : 10 subtract, 01 add, 00/11 nothing; then arithmetic shift right of . steps.
- Booth operations = number of changes between neighbouring multiplier bits (with ). Run of 1s costs 2 whatever its length.
- Most negative multiplicand needs a one-bit-wider add.
- Radix-4: digits from triples; partial products.
- Array multiplier: AND gates, adders of bits.
Traps and GATE patterns
Connections
Across subjects
Within this subject
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
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
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
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
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 answerHide
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 answerHide
bits.
Question 3
The multiplier is in 4 bits (1111). How many operations does Booth's algorithm use and what is ?
Show answerHide
One subtraction at the first step (pair 10), then pairs 11, 11, 11 do nothing: 1 operation. The result is .
Question 4
How many partial products does radix-4 Booth need for a 16-bit multiplier?
Show answerHide
8 (one per bit pair).
Revision card
One-screen revision
- Shift-and-add: steps, add if , shift right; adds = number of 1s. Product bits.
- Booth: 10 subtract, 01 add, else nothing; arithmetic shift of ; operations = bit changes.
- . Radix-4: digits to , partial products.
- Most negative needs one extra bit. Array multiplier: ANDs, 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
My notes (saved in this browser)