Multiplication by shifting: 1011 × 8 — binary arithmetic

edge caseshifting is multiplying by 2ⁿ

Answer

00000001011000

Why this example is worth doing

Multiplying by a power of two is a left shift by the exponent, appending zeros. It is the cheapest operation in the whole set — a shift is just wiring, with no gates at all in a fixed-amount shifter — and it is why compilers replace multiplication by constants with shift-and-add sequences. The page notes the matching right shift for division and warns that arithmetic and logical right shifts differ for signed values.

Try your own input in the Binary arithmetic. Add, subtract, multiply and divide in binary with every carry and borrow shown.

How the answer is reached

0001011 x 0001000 (7-bit unsigned)

0001011 x 0001000 (7-bit unsigned) — columns operand, bits, hex, unsigned, signed
operandbitshexunsignedsigned
A00010110x0B1111
B00010000x0888

Shift and add: one partial product per multiplier bit, each shifted left by its bit index. A 7 x 7 multiply needs 14 bits of product.

0001011 x 0001000 (7-bit unsigned) — columns bit index, multiplier bit, partial product, meaning
bit indexmultiplier bitpartial productmeaning
00000000000000000 (multiplier bit is 0)
10000000000000000 (multiplier bit is 0)
20000000000000000 (multiplier bit is 0)
3100000001011000|A| << 3
40000000000000000 (multiplier bit is 0)
50000000000000000 (multiplier bit is 0)
60000000000000000 (multiplier bit is 0)

sum of partial products00000001011000

product00000001011000 = 88

Compare with

Open the Binary arithmetic

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Fractions are converted digit by digit and shown to a stated number of places rather than rounded silently.

Sources

  • Knuth, The Art of Computer Programming, Vol. 2, §4.3.1 “The Classical Algorithms” (1997)