In the grand old tradition of projects for project’s sake, A friend asked me to assist him with building a calculator with a difference – it runs on water, not electricity. The logic circuits will be built using water as their current, and pressure as their voltage. While this is a totally impractical and superfluous machine, it sounds fun, and that’s enough to inspire me.

First, it helps to start with the basic function of a normal calculator. Calculators, like all computing machines, run on binary numbers – that is, they don’t use numbers 0 to 9, just 0 and 1. The first few numbers in binary are:

0-0

1-1

2-10

3-11

4-100

And so on. Essentially, this means that inputting numbers into the calculator will need them to be in binary, so we either convert them by hand, or build a mechanism to do it for us. We haven’t worked on this bit yet – our focus has been on the calculator itself.

So now you have your 2 numbers in binary – and you want to add them together, which is the easiest calculation to carry out. To add them together, we need logic gates – these are simple devices that take inputs, and give outputs, based on some rule. Normally they are electronic, but we want to make water based ones – however, their function is essentially the same. To make the addition, we need 3 kinds of gates: AND gates, OR gates, and XOR gates.

AND gates are fairly simple – they take 2 inputs, and if both inputs are 1, they output 1. Otherwise, they output 0. The name tells you this – you need one AND the other to get output.

OR gates are also simple – they take 2 inputs, and if at least one input is 1, they output 1. If both inputs are 1, they still output 1. Again, the name tells you – one OR the other.

XOR gates are almost identical to OR gates, with one difference – if both inputs are 1, the output is 0. Otherwise, they are the same – if both inputs are 0, output is 0, and if either is 1, the output is 1. XOR is short for exclusive OR.

Right – you have these little circuits that take some inputs, and give some outputs. Now what? Firstly, we need to add the digits together one by one – that is, we will make a little module that adds the nth binary digit from the first number to the nth from the second, and connect lots of these modules together to add all the digits.

This is where we get our first little circuit – called a half-adder. It adds one binary digit to another one, and outputs the result. There are 2 inputs – the 2 digits to be added. There are also 2 outputs – one output digit, and the carried digit – the digit that goes into the next column. This is similar to something we do during long addition – when you add 7 and 9, the 6 goes in that column, and you write a small 1 above the next column to add into it.

If you follow the logic diagram, you can figure out how the adder works; it is very difficult to adequately explain the functioning in text.

This is a nifty little circuit, but it has a flaw – it only outputs the carry digit, it can’t take it into account in the input. To remedy this, you attach two half adders together to make a full adder circuit, which adds the carry bit to the result:

This one has 3 inputs – the 2 binary digits to be added, and the carry bit from the previous adder. Now, you can take a whole army of these and connect them, linking the Cout from one to the Cin from another.

You can now add as many bits as you want.