Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
what is the result of 10^2....This is an example of exclusive OR. How does it works..pls help
Posted

Assuming you are working in decimal, first convert to binary (it is easier to read XOR in binary, normally you would work in hex for compactnes).
10 Dec = 1010 Binary
02 Dec = 0010 Binary


Exclusive OR (or XOR for short) gives a One when the bit in that position is a one on either of the inputs, and a zero on the other. In cases where the input bit is the same, XOR always gives a zero.
Input1 Input2 Output
  0      0       0
  0      1       1
  1      0       1
  1      1       0

So if you XOR 10(dec) with 2(dec) you get 8(dec):
         Dec  Bin 
Input1   10   1010
Input2   02   0010
Output   08   1000
 
Share this answer
 
I found this with google:

http://mathworld.wolfram.com/XOR.html[^]

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900