Half and Full adders

Half adders are the combination of an XOR and an AND gate and they are the basis of binary addition (and as such of every other operation too).

Full adders are made up of two half adders combined in a specific way – the difference is full adders also consider a carry input.

Before getting into this, let’s explain a bit about binary and introduce a new gate: the XOR.

Binary format

In everyday life, we use the decimal system, which uses a total of 10 numbers: 0 to 9. This means that every number is the sum of a series of multiplications of powers of 10. For example, think of the number 384.

  • 300 + 80 + 4
  • 3*100 + 8*10 + 4*1
  • 3*10^2 + 8*10^1 + 4*10^0

Notice that the exponents start at 0 and increase towards the left. Every time we add a digit, a new power of 10 is needed.

In binary, the system is based on the same principle, only instead of powers of 10 we use powers of 2. Let’s think of a small number to start with: 7.

  • 4 + 2 + 1
  • 1*4 + 1*2 + 1*1
  • 1*2^2 + 1*2^1 + 1*2^0

There are only two possible numbers in binary: 0 and 1. The way you translate from decimal to binary is by finding what powers of two add up to that decimal number. 7 is made up of 2^1, 2^1 and 2^0, thus its binary equivalent is 111. Let’s see another example: the number 25.

  • 16 + 8 + 1
  • 1*16 + 1*8 + 0*4 + 0*2 + 1*1
  • 1*2^4 + 1*2^3 + 0*2^2 + 0*2^1 + 1*2^0

Can you see the pattern? 25 in decimal is 11001 in binary, because we have one 16, one 8, zero 4s, zero 2s and one 1.

The XOR gate

You remember OR from a few posts ago? Now it’s time to study its more complicated brother, the Exclusive OR. This gate is often abbreviated as EOR, EXOR or XOR.

The output of an XOR gate is true only when exactly one of its inputs is true.

Here is the truth table:

ABA XOR B
000
011
101
110

The hardware representation:

Making it in Minecraft is slightly more complicated: