Binary Operations


When working with binary numbers, there are three logical operations not found in normal math:

  • AND
  • OR
  • and XOR

AND

To perform the AND operation:

  • you take two binary numbers and compare them one place at a time

  • If both numbers have a 1 in both places, then the resultant number is a 1

  • If not, then the resultant number is a 0

  • e.g.,

OR

  • OR operation checks to see whether there is a 1 in either or both numbers in a given place

  • If so, then the resultant number is 1

  • If not, the resultant number is 0

  • e.g.,

XOR

The exclusive OR (XOR ) checks to see whether there is a 1 in a number in a given place, but not in both numbers at that place.

  • If it is in one number but not the other

    • then the resultant number is 1
  • If not, the resultant number is 0

  • e.g.,

  • XOR is reversible

    • XOR the resultant number with the second number and you get the first number