Half Adder
A half adder adds two single bits, producing a sum bit and a carry bit, but accepts no carry in.
What it does
A half adder adds two one-bit numbers, A and B. It produces a sum bit and a carry bit. It is called half because it has no input for a carry coming from a lower position, which limits how it can be chained.
Truth table
| A | B | CARRY | SUM |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
The gate equations
- SUM = A XOR B, the addition of two bits without carry.
- CARRY = A AND B, which is 1 only when both inputs are 1.
- So a half adder is one XOR gate and one AND gate.
In code
python
def half_adder(a, b):
s = a ^ b # sum bit
c = a & b # carry bit
return s, cWhy it is not enough alone
Adding multi-bit numbers requires propagating a carry from each position into the next. A half adder cannot accept that incoming carry, so only the least significant bit of an unsigned addition can use one directly. Every other position needs a full adder.
Its place in arithmetic
Despite the limitation, the half adder is the conceptual seed of all binary arithmetic. A full adder is built from two half adders plus an OR gate, and ripple or carry-lookahead adders are chains of full adders. Understanding the half adder makes the rest follow naturally.