Wednesday, September 4, 2013

XOR vs Addition, AND vs Multiplication



Hi everyone!

In this blog post, all numbers with a "b" after them are designated binary numbers. (the extra zeroes in front are for illustration purposes only)

XOR vs Addition

The logical operator XOR and addition may be very similar, but they are not the same.

Examples:

1101b + 0110b = 10011b but 1101b XOR 0110b = 1011b
1001b + 0011b = 1100b but 1001b XOR 0011b = 1010b

Truth table for XOR (Exclusive OR):
1 XOR 1 = 0
1 XOR 0 = 1
0 XOR 1 = 1
0 XOR 0 = 0

XOR is like addition if we let 0 represent an even number and 1 represent an odd number:
odd + odd = even
even + odd = odd
odd + even = odd
even + even = even

AND vs Multiplication

Likewise, the logical operator AND and multiplication may be very similar, but they are not the same.

Examples:
1101b × 0010b = 11010b but 1101b AND 0010b = 0000b
1100b × 1110b = 10101000b but 1100b AND 1110b = 1100b

Truth table for AND:
1 AND 1 = 1
1 AND 0 = 0
0 AND 1 = 0
0 AND 0 = 0

And likewise, AND is like addition if we let 0 represent an even integer and 1 represent an odd integer:
odd × odd = odd
odd × even = even
even × odd = even
even × even = even

Hopefully this clears any confusion up between arithmetic and two logic gates sometimes labeled as arithmetic. As always, love any comments and thanks as always.

Eddie


This blog is property of Edward Shore. 2013

  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...