How to Master Binary Multiplication
Multiply binary numbers with the shift-and-add method: partial products, adding them with carries, and why multiplying by 2 is just a left shift.
How to Multiply Binary Numbers
Most people assume binary multiplication is a completely alien process, but it is the same arithmetic you learned in primary school, just with digits that are only ever 0 or 1. The real skill is not memorizing a new table; it is recognizing that binary multiplication rules reduce to a pattern of shifts and additions. This pattern lets you multiply any two binary numbers by hand, check your work, and understand exactly what your calculator or compiler is doing under the hood. Learn to multiply binary numbers by hand.
The Multiplication Rules: Zero and One
Before you can multiply, you need the four facts that make up the entire binary multiplication ruleset. In binary, each digit is a bit, and the multiplication table is almost embarrassingly short: 0 times 0 is 0, 0 times 1 is 0, 1 times 0 is 0, and 1 times 1 is 1. That is it. No carries are generated inside a single multiplication step because you are only ever multiplying by 0 or by 1, never by 2 through 9. This simplicity is why binary multiplication is often described as a series of decisions: for each bit in the multiplier, you either copy the multiplicand (if the bit is 1) or write a row of zeros (if the bit is 0).
The practical consequence is that the multiplication rules are not about multiplication at all; they are about addition. Every 1-bit in the multiplier produces a partial product that is the multiplicand shifted left by the bit's position, and every 0-bit produces a row of zeros. The final product is the sum of all those partial products. This is the standard shift and add multiplication algorithm, and it is the foundation of every hardware multiplier ever built. If you can add binary numbers and you can shift a bit pattern left, you can multiply.
Long Multiplication with Partial Products
Here is where the process becomes concrete. To multiply two binary numbers, write them vertically, exactly as you would for decimal long multiplication. Then, for each bit of the multiplier, from the least significant bit on the right to the most significant bit on the left, write a partial product. If the multiplier bit is 1, write the multiplicand. If it is 0, write a row of zeros. Shift each new partial product one place to the left relative to the previous one. Finally, add all the partial products using binary addition.
Let us walk a clean example. Multiply 1011 (eleven) by 101 (five). The multiplicand is 1011, the multiplier is 101. The rightmost multiplier bit is 1, so write 1011. The next bit is 0, so write 0000, shifted left by one place. The leftmost bit is 1, so write 1011, shifted left by two places. Align them and add: 1011 + 0000 + 101100. That sum is 110111, which is fifty-five in decimal. The partial products were 1011, 0000, and 1011, and their sum is 110111.
Try a second example to see the pattern stick. Multiply 1101 (thirteen) by 11 (three). The multiplier has two 1-bits, so you get two partial products: 1101 and 1101 shifted left one place. Adding 1101 and 11010 gives 100111, which is thirty-nine. The partial product sum is 100111, and that matches thirteen times three. The method never changes: copy, shift, add.
Multiplying by Powers of Two with Shifts
One special case deserves its own treatment because it is the key to the whole shift and add multiplication approach. Multiplying a binary number by two is identical to shifting every bit one place to the left and appending a zero on the right. Multiplying by four is a left shift of two places, by eight a left shift of three places, and so on. This is the rule: left shift by one bit is always equivalent to multiplication by two, barring overflow. It is exact, it is fast, and it is why computers multiply the way they do.
For example, 101 (five) shifted left once is 1010 (ten). Shifted left twice it is 10100 (twenty). This works for any width, as long as the result fits in the available bits. When you see a multiplication like 1101 times 100, you do not need the full algorithm: 100 is 2 squared, so the product is 1101 shifted left two places, which is 110100 (fifty-two). The partial products in a general multiplication are just these shifts, one per 1-bit in the multiplier, added together. Recognizing powers of two lets you skip the busywork.
This is also where the common mistake lives. A left shift is safe for unsigned values and for signed values as long as no bits fall off the top and the sign does not change. If you shift a signed number left and the sign bit flips, you have overflow, and the result is wrong. The C standard (C17 6.5.7) says that left shifting a signed value is defined as multiplication by 2^k, provided the result is representable; if it is not, the behavior is undefined. So shift with your eyes open.
Worked Examples with Column Layout
Reading about the algorithm is one thing; seeing it in columns is another. Below are several worked examples, each showing the multiplicand, multiplier, partial products, and final sum. Study the alignment; that is where most hand-written errors happen. If you line up the partial products one place off, the sum is wrong by a factor of two.
Example 1: 1010 (ten) times 101 (five). Partial products: 1010, 0000, 1010. Sum: 110010 (fifty).
Example 2: 1111 (fifteen) times 1111 (fifteen). Partial products: 1111, 1111, 1111, 1111. Sum: 11100001 (two hundred twenty-five).
Example 3: 1001 (nine) times 101 (five). Partial products: 1001, 0000, 1001. Sum: 101101 (forty-five).
Example 4: 110 (six) times 11 (three). Partial products: 110, 110. Sum: 10010 (eighteen).
Example 5: 10101 (twenty-one) times 101 (five). Partial products: 10101, 00000, 10101. Sum: 1101001 (one hundred five).
Example 6: 1000 (eight) times 1000 (eight). Partial products: 1000, 0000, 0000, 1000. Sum: 1000000 (sixty-four).
Example 7: 111 (seven) times 111 (seven). Partial products: 111, 111, 111. Sum: 110001 (forty-nine).
Example 8: 1011 (eleven) times 11 (three). Partial products: 1011, 1011. Sum: 100001 (thirty-three).
Each of these follows the same rule: one partial product per 1-bit in the multiplier, each shifted left by its bit position, then added with binary addition. Check any one of them by converting to decimal and multiplying; the column layout is the whole game.
Signed Numbers and Two's Complement Multiplication
Everything so far assumed unsigned numbers. Real hardware and most programming languages use two's complement for signed integers, and that changes the multiplication rules. The good news is that the shift and add multiplication algorithm still works for two's complement, but you must sign-extend the partial products to the full width of the result before adding them. Sign extension means copying the sign bit into every new higher-order position, so a negative multiplicand like 1111 (which is -1 in four-bit two's complement) becomes 11111111 when widened to eight bits.
For example, multiply 1101 (-3 in four-bit two's complement) by 0011 (3). The multiplicand is negative, so each partial product must be sign-extended to the result width, which is eight bits. The partial products are 11111101, 11111010, 00000000, and 00000000. Adding them gives 11110111, which is -9 in eight-bit two's complement. That is correct: -3 times 3 is -9. Without sign extension, you would get the wrong answer because the leading 1s would be lost.
Sign-extend each partial product to eight bits: 11111011, 11110110, 00000000, 00000000. Sum them to get 100001001, but you are working in eight bits, so the leading 1 is a carry out and is discarded, leaving 00001111, which is fifteen. That works because two's complement multiplication is modular: the result is correct modulo 2^8, and the carry out is ignored. This is why the binary multiplication rule for signed two's complement says the final product width is the sum of the operand widths; overflow is only a problem if the result cannot be represented in that width.
For efficiency, some implementations use Booth's algorithm, which handles the sign bits without special-casing, but the standard shift and add method with sign extension is simpler to do by hand. If you are multiplying two signed numbers and the result does not fit in the width, you get overflow, and the truncated result is wrong. Detect it by checking that the sign bits of the operands and the product are consistent: if both operands are positive and the product is negative, or both are negative and the product is positive, you have overflow.
| Operation | Rule | Example |
|---|---|---|
| Bit multiply | 0 × 0 = 0, 0 × 1 = 0, 1 × 0 = 0, 1 × 1 = 1 | 1 × 1 = 1 |
| Partial product | One per 1-bit in multiplier | 1011 × 101 gives 1011, 0000, 1011 |
| Shifting | Left shift by bit position | 1011 shifted left twice is 101100 |
| Summing | Add all partial products with binary addition | 1011 + 0000 + 101100 = 110111 |
| Signed operands | Sign-extend each partial product to full width | 1101 (-3) sign-extended to 11111101 in 8-bit |
| Overflow (signed) | Result truncated to width does not match mathematical product | -3 × 3 = -9, 8-bit result 11110111 is correct |
| Powers of two | Left shift by k equals multiply by 2^k | 101 × 100 = 10100 |
Common Mistakes and How to Avoid Them
The most frequent error in hand multiplication is a sign extension mistake. When you widen a signed value from, say, 4 bits to 8 bits, you must replicate the sign bit into all the new upper positions. If you take -1 as 1111 and just pad with zeros to get 00001111, you have turned -1 into 15. This is exactly the failure mode that turns a correct multiplication into garbage. Always ask: is this value signed or unsigned? If signed, fill with the sign bit; if unsigned, fill with zeros.
The second classic error is missing overflow. Adding two positive signed numbers that exceed the maximum flips the sign bit. For multiplication, overflow happens when the product does not fit in the chosen width. A quick check: if both operands are positive and the result's sign bit is 1, or both are negative and the result's sign bit is 0, you have overflow. The C standard says that signed overflow is undefined behavior, so a compiler can assume it never happens; do not rely on wrapping for correctness.
Third, alignment of partial products. A one-place shift error in any row changes the product by a factor of two. In the column layout, count the bit position of each multiplier bit and shift accordingly. If the multiplier has a 0 in the middle, you still write a row of zeros; do not skip it, because skipping changes the positional value of all subsequent rows. The row of zeros is a placeholder that keeps the alignment honest.
Shifts and the Right Shift Trap
We covered left shifts as multiplication by powers of two, but right shifts deserve their own warning. A right shift of an unsigned value always fills with zeros, which is a logical shift and divides by two, discarding the remainder. A right shift of a signed value can be logical or arithmetic, depending on the language and platform. In C, right shifting a signed negative value is implementation-defined; in practice, GCC and Clang use an arithmetic shift, filling with ones, which divides by two but rounds toward negative infinity. This is the arithmetic shift right: it preserves the sign bit and is equivalent to dividing by two for signed values, as long as the value is negative.
The trap is assuming arithmetic shift for negatives everywhere. JavaScript's >> is arithmetic for 32-bit signed integers, but >>> is logical. Python's >> is arithmetic because Python integers are infinite-precision, so shifting right a negative number keeps the sign. If you are porting code, test the behavior. For multiplication, right shift is rarely used, but for division by powers of two, it is the standard trick. However, note that a right shift of a negative value in C is not a portable division; if you need division truncating toward zero, use / instead, because the shift may round differently.
Another subtlety: a left shift by one bit is always equivalent to multiplication by two, barring overflow. This is true for both signed and unsigned, as long as the sign bit does not change. If you shift a signed positive number so far left that the sign bit becomes 1, you have overflow, and the result is undefined in C. For unsigned, overflow simply wraps modulo 2^width, which is well-defined. Know your width and your language's rules before you shift.
Putting It All Together in Practice
You now have everything you need to multiply any two binary numbers by hand. Start by checking the sign of each operand. If both are unsigned, use the plain shift and add multiplication algorithm: write the multiplicand, then for each 1-bit in the multiplier, write the multiplicand shifted left by that bit's position, and for each 0-bit, write a row of zeros. Add the partial products using binary addition, being careful with carries. If either operand is signed and you are using two's complement, sign-extend each partial product to the full width of the result before adding, and discard any carry out of the top bit.
For a quick sanity check, convert to decimal and multiply. For a deeper check, verify the partial product sum in decimal. If you are multiplying by a power of two, just shift left; this is the shift and add multiplication trick that makes binary multiplication fast in hardware. If you are multiplying two signed numbers and the result does not fit, expect overflow; in C, that is undefined behavior, so avoid it by using a wider type or checking beforehand.
Finally, remember the failure case: when you are multiplying by hand at 1am and the columns blur, stop, rewrite the problem with more spacing, and add each partial product twice. A single misaligned row or a lost carry is enough to ruin the answer. Take the extra thirty seconds to check your work; it is faster than redoing the whole multiplication.
Common Questions
What exactly is the difference between a carry and an overflow flag, and how do I detect each from the operands and result?
A carry out happens when an addition or multiplication produces a bit beyond the most significant position, which is normal for unsigned arithmetic. Overflow happens when a signed result is too large in magnitude to fit the width, and the sign bit flips incorrectly. For addition, detect overflow when the carry into the sign bit differs from the carry out of it. For multiplication, overflow occurs when the truncated product does not match the mathematical product in the chosen width. In binary multiplication, if you multiply two positive signed numbers and the result's sign bit is 1, you have overflow; likewise if you multiply two negatives and get a negative result.
How do I convert a negative decimal number to binary by hand?
The two's complement method is to write the positive number in binary, invert every bit, then add one. For example, to get -5 in four bits, start with 0101, invert to 1010, add one to get 1011. The reason it works is that two's complement is defined as the number you add to the positive value to get zero modulo 2^width. If you prefer, you can also work backward: find the largest power of two that fits, subtract it, and repeat, then flip and add one. The 'flip and add one' rule is not magic; it is the mathematical inverse of the operation that produces zero.
What is the difference between a logical shift and an arithmetic shift, and when does each language use which?
A logical shift fills the vacated bits with zeros, while an arithmetic right shift fills them with the sign bit, preserving the sign for signed values. In C, right shifting an unsigned value is always logical, filling with zeros. Right shifting a signed negative value is implementation-defined per C17 6.5.7; on GCC and Clang it is arithmetic, so it fills with ones, but the standard does not require it. JavaScript's >> operator is arithmetic for signed 32-bit integers, and >>> is logical. Python has infinite-precision integers, so a right shift is arithmetic for negative numbers by default. For multiplication, a left shift is the same for both logical and arithmetic, as long as no bits overflow.
When I add two 8-bit numbers in a calculator, when do I get a carry out, and when do I get overflow? Can I have both at once?
You get a carry out when the sum of two unsigned 8-bit numbers exceeds 255, producing a 9th bit. You get overflow when the sum of two signed 8-bit numbers exceeds 127 or goes below -128, flipping the sign bit. You can have both at once: for example, adding 200 and 100 in 8-bit unsigned gives 300, which is 44 with a carry out; as signed, 200 is -56 and 100 is 100, their sum is 44, which is correct, so no overflow in that case. But adding 127 and 1 gives 128 as unsigned with no carry, and -128 as signed, which is overflow. Both flags are independent; carry is for unsigned, overflow for signed, and each is detected from the operands and result separately.
What is the exact algorithm for binary multiplication and division, and how do I handle signed operands?
For multiplication, the algorithm is shift and add: for each bit of the multiplier from least significant, if it is 1, add the multiplicand to an accumulator, then shift the accumulator and the multiplier right together. For signed operands, you must sign-extend the partial products and use two's complement arithmetic, or use Booth's algorithm, which handles the sign bit directly. For division, the restoring or non-restoring algorithm shifts the dividend and subtracts the divisor, checking the remainder sign. Signed division requires adjusting the quotient and remainder to match the sign of the dividend. The key is that all operations work on the bit pattern; the interpretation as signed or unsigned is a layer on top.
How do I verify my hand-calculated binary answer is correct without a calculator?
Convert the multiplicand and multiplier to decimal, multiply them, then convert the product back to binary and compare. For example, 1011 × 101 is 11 × 5 = 55, and 110111 is 55. A second check is to add the partial products in decimal: 1011 is 11, 0000 is 0, and 101100 is 44, and 11 + 0 + 44 = 55. For signed numbers, convert to decimal using two's complement, multiply, and check the sign and magnitude. If you have time, use the casting out nines equivalent: in binary, the digit sum modulo 2 minus 1, but the decimal conversion is simplest and least error-prone.
What do GCC and Clang actually do for right shift of negative numbers, and how do I write portable code?
On all mainstream platforms, GCC and Clang compile a right shift of a signed negative integer as an arithmetic shift, filling the vacated bits with the sign bit. This is the behavior you observe, but the C standard (C17 6.5.7) explicitly leaves it implementation-defined, meaning a conforming compiler could choose a logical shift instead. To write portable code, avoid right-shifting signed negative values altogether; cast to an unsigned type first, or use division, but be aware division truncates toward zero, not negative infinity. If you need arithmetic shift semantics portably, implement it with a conditional: if the value is negative, shift right logically and OR in the sign mask.