Hacker News new | ask | show | jobs
by kleiba 1288 days ago
That's correct, and here's a further illustration.

Consider adding two single bits, X and Y - you'll get the following sums, denoted in binary (column CM):

    X Y | CM
    ----+---
    0 0 | 00
    0 1 | 01
    1 0 | 01
    1 1 | 10
As you'll note, the M-bit is just XOR and the C-bit is AND (google "half-adder" if you're into hardware).

And as we remember from school, the carry (C-bit) always has to be added to the next column to the left, that's why we shift it by one bit (aka multiplication by 2).