digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

How to build a half adder from logic gates

A half adder adds two single bits and takes exactly two gates: one XOR gate produces the sum bit, and one AND gate produces the carry bit.

It is the smallest piece of arithmetic hardware there is: two inputs, two outputs, and no carry coming in (that is what makes it a half adder). Add A and B, get a sum bit S and a carry bit C.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

What you need

Step by step

  1. Place two inputs, A and B, the two bits you want to add.
  2. Wire both inputs into an XOR gate. Its output is the sum bit S: it is 1 when the bits differ, which is exactly when the column adds to 1.
  3. Wire the same two inputs into an AND gate. Its output is the carry bit C: it is 1 only when both bits are 1, which is the case 1 + 1 = 10 that overflows the column.
  4. Send the XOR output to a probe labelled S and the AND output to a probe labelled C. That is the whole half adder.

Half adder truth table

ABSC
0000
0110
1010
1101

Read the last row: 1 + 1 = 2, which is 10 in binary, so the sum bit is 0 and the carry is 1. Chain a half adder's carry into a full adder and you can add wider numbers.

You can also read the full theory in the lesson on half adder. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.

Build more parts from gates

Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab and course.

Open the half adder in the lab →

Frequently asked

What gates make a half adder?

A half adder is one XOR gate and one AND gate. The XOR gives the sum bit (A XOR B) and the AND gives the carry bit (A AND B). No other gates are needed.

What is the difference between a half adder and a full adder?

A half adder adds two bits and has no carry input, so it cannot be chained. A full adder adds three bits (two operands plus a carry-in), which lets you cascade them to add multi-bit numbers.

Why does the half adder use an XOR gate?

Because the sum of two bits is 1 exactly when the bits differ (0+1 or 1+0) and 0 when they match. That is the XOR truth table, so the sum bit is A XOR B.