1
$\begingroup$

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   ?
$\endgroup$
  • $\begingroup$ You go bit by bit through each of the values of a and b. This would give you a 11110 for an answer. $\endgroup$ – JB King Apr 19 '13 at 18:15
  • $\begingroup$ He already is going through bit by bit. What he wants to know is what to do with values that aren't given. $\endgroup$ – Joe Z. Apr 19 '13 at 19:09
4
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.