Binary and addition

Why Addition Uses Both AND and XOR

Adding one bit to another answers two questions: is one unit left in this column, and does anything carry to the next column? XOR answers the first and AND answers the second, so addition needs both.

Two questions, two gates

XOR outputs 1 when exactly one input is 1, meaning one unit is left in this column. AND outputs 1 when both inputs are 1, meaning a pair formed and goes to the next column.

ABXOR → S · SumAND → C · Carry
0000
0110
1010
1101
The inputs 00, 01, 10 and 11 shown against XOR and AND: XOR is 1 for 01 and 10, and AND is 1 only for 11.
Outputs of three gates for the four inputs
ABXORANDOR
00000
01101
10101
11011

Why OR doesn't work

OR outputs 1 whenever at least one input is 1. It matches XOR for the first three rows, but for A=1, B=1 it outputs 1 when the column should keep 0, so OR can't give the sum bit.

You also can't simply add the AND and XOR outputs together. A 1 from AND stands for two units in the next column, while a 1 from XOR stands for one unit in this column.

How a full adder reuses them

In a full adder, the first half adder uses XOR and AND on A and B, and the second uses XOR and AND on that sum and Cin. The OR there only combines the two half adders' carries, which are never both 1.

Check yourself

  1. For A=1, B=1, what do XOR, AND and OR output?

    Answer

    XOR gives 0, AND gives 1 and OR gives 1. The correct result keeps 0 in the column and carries 1, so XOR and AND are the right pair.

  2. For A=0, B=1, what do XOR and AND output?

    Answer

    XOR gives 1 and AND gives 0: one unit stays in the column and nothing carries.

  3. Why do the outputs C=1, S=0 mean 2?

    Answer

    C is in the next column up and counts two units; S is in this column and counts one. 2×1+0=2, written 10₂.