BiggestQuitter's blog

By BiggestQuitter, history, 6 years ago, In English

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Think of it this way, when you sum two numbers you get: 2 * (bits set in both numbers) + (bits set in one number but not set in the other).

»
6 years ago, # |
  Vote: I like it +19 Vote: I do not like it

think of how you add numbers in binary.
0 + 0 = 0
0 + 1 = 1
1 + 1 = 0 (with 1 carry)

so XOR calculates the addition without carry and AND calculates the carry. multiplying it by 2 shifts it to the left.