How a computer multiplies: shift and add
A computer has no multiplication table. It multiplies with the one thing it already does well: adding shifted copies of a number. Here it is, one bit at a time.
Press Next to walk through 5 × 3, then try your own numbers.
What just happened
Multiplication is repeated addition, and long multiplication is the smart way to organize it: for each digit of the multiplier, you add a shifted copy of the multiplicand. In base 10 each digit still forces a real multiply. In base 2 that vanishes, because a digit is only 0 or 1. So every step is either add a shifted copy of A (when the bit is 1) or add nothing (when it is 0). Shifting left by one position multiplies by 2, so shifting A left by i and adding it in handles the i-th bit of B.
That is why a CPU needs no special multiply hardware to get started: a shifter to slide A left, and the adder you already built to accumulate the partial products. Do it for every bit of B and you have A × B. The dedicated multiplier circuit just does all the shifts and adds at once with a tree of adders. Division runs the same idea in reverse (shift and subtract), and the whole toolkit, add, subtract, multiply, lives in the ALU. It all traces back to logic gates built from transistors. See the sibling walkthrough on how a computer adds first if the carry is new to you.
Common questions
How does a computer multiply two numbers?
By shift and add. It reads the multiplier one bit at a time; for each 1 at position i it adds the other number shifted left by i (a partial product), and adds nothing for a 0. Summing those shifted copies gives the product, using a shifter plus the adder.
How does binary multiplication work?
Like long multiplication, but base 2 makes it simple: each partial product is either the multiplicand shifted left (multiplier bit 1) or all zeros (bit 0). Line them up by shift and add. No multiplication table needed.
What is shift-and-add multiplication?
The standard binary multiply algorithm: for each bit i of B that is 1, add A shifted left by i into a running product. Shifting left by i multiplies by 2^i, so the shifted copies for B's 1 bits sum to A × B.
Why is binary multiplication easier than decimal?
Because each multiplier digit is only 0 or 1: a 1 means add a shifted copy, a 0 means add nothing. There is no per-digit multiply against a table. That simplicity is a big reason computers work in binary.
How does a computer divide?
By the reverse idea, shift and subtract: repeatedly subtract shifted copies of the divisor, writing a 1 in the quotient when it fits and a 0 when it does not. It is trickier and usually slower, but uses the same shifter and adder/subtractor.