3 ms·
Actually bit addition in ALU is usually implemented using an XOR gate (with an AND gate to compute carry)...But as "diff" is essentially addition (over compleme
by 2510c39011c5 12y ago
Actually bit addition in ALU is usually implemented using an XOR gate (with an AND gate to compute carry)...But as "diff" is essentially addition (over complement numbers), they mean the same thing...
Also note that XOR is associative -- that's the key to prove the XOR swapping...
For those who are interested in binary tricks, there are several good resources:
* HAKMEM, http://goo.gl/F6sBjt http://goo.gl/F6sBjt
* Hacker's Delight, http://goo.gl/llQumw http://goo.gl/llQumw
- thomasmarcelis 12y agoHacker's Delight is one of the most fun tech books I have read. It is filled with fun tricks and algorithms, with each of them adequately explained.
- 2510c39011c5 12y agoI agree. The book itself is very thin; but the content is incredibly rich...