Computing Library › Digital Logic & Circuits
Digital Logic & Circuits

Half Adder

A half adder sums two single bits, producing a sum bit and a carry bit, but cannot accept an incoming carry.

What it does

A half adder is the simplest arithmetic circuit. It takes two one-bit inputs, A and B, and produces two outputs: the sum S and the carry C. The sum is the low bit of A+B and the carry is the high bit.

Logic

The sum is the exclusive-OR of the inputs: S = A XOR B. The carry is the AND of the inputs: C = A AND B. Only when both inputs are 1 does the two-bit result 10 overflow the single sum column into a carry.

Truth table

ABSC
0000
0110
1010
1101

Limitation

A half adder has no third input for a carry arriving from a lower bit position. That makes it unusable on its own for multi-bit addition, where each column past the first must accept a carry-in. The full adder fixes this.

In code

python
s = a ^ b
c = a & b