World's most popular travel blog for travel bloggers.

[Solved]: confused about XORing and addition modulo 2

, , No Comments
Problem Detail: 

it's my understanding that when you XOR something, the result is the sum of the two numbers mod 2. why then does 4^2 = 6 and not 0? 4+2=6, 6%2 doesn't equal 6. I must be missing something about what 'addition mod 2' means - but what?

100 // 4

010 // XOR against 2

110 = 6 // why not zero if xor = sum mod 2?

Asked By : David Holiday

Answered By : Rick Decker

The confusion here stems from a missing word. A correct statement is "The result of XORing two bits is the same as that of adding those two bits mod 2."

For example, $(0+1\bmod 2)=1=(0\text{ XOR }1)$

and

$(1+1\bmod 2)=0=(1\text{ XOR }1)$

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/41664

0 comments:

Post a Comment

Let us know your responses and feedback