|
|
|
|
|
by ggrrhh_ta
1288 days ago
|
|
The first one is just the binary sum without carry (x xor y) and then adding the carries of that sum (x&y) shifted by 1 bit (2*(x&y)), still the addition of the carries can in turn produce carries, but that is taken care of by the normal "+" which is addition with carry. |
|
Consider adding two single bits, X and Y - you'll get the following sums, denoted in binary (column CM):
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).