XOR for 10 and 20

5.5k Views Asked by At

I know that this is the XOR truth table.

A B  Q
------
0 0  0
0 1  1
1 0  1
1 1  0

I have $a = 10; and b=20$; Their respective binaries are $a=1010$; and $b=10100$; $a$ XOR $b$. In computer science I can write it as $a$^$b$

when I try to write truth table, I have 1 place empty, what to do. SO here is my approach for $10$ XOR $20$

a  b  RESULT
----------
1  1   0
0  0   0
1  1   0
0  0   0
?  0   ?
1

There are 1 best solutions below

0
On BEST ANSWER

Normally, you'd assume that any leading bits are zero. Also, the bits should be aligned by least significant, not most significant. So what you really want is this:

a  b  a^b
----------
0  1   1  <- because a is less than 10000, pad it out
1  0   1
0  1   1
1  0   1
0  0   0

So your answer is 30.