**by Paul Curzon, Queen Mary University of London** **and Adrian Johnstone, Royal Holloway, University of London**

*Charles Babbage famously designed the first computer: a steam powered contraption that was never built. At its core was something very simple and elegant: a cunning contraption that allowed his machines to store numbers and do arithmetic, all made of Victorian tech: metal wheels and levers.*

Babbage’s Analytical Engine, had it been built, would have been the first working general-purpose computer. The size of a factory, and powered by a steam engine, it was the ultimate cunning contraption. A giant whirring, clanking, puffing mechanical brain. Babbage’s first attempt at mechanical computation, though, was a simpler machine, the Difference Engine. It could only do a fixed, if very useful, kind of calculation. It computed what are called polynomials: patterns of additions and multiplications. It used a complicated adding mechanism. Later, whilst working on designs for his ambitious Analytical Engine he thought of a much simpler adder (described below). His second Difference Engine used this new adder and so needed about 16,000 fewer parts! The Science Museum built it in the twentieth century.

## Representing Numbers

First he had to devise a way to represent numbers. Unlike modern computers which use binary, so only two digits, Babbage stuck to decimal. He was going to do all his calculations using our normal ten digits, 0 – 9. But how? His solution was to use metal cog-like wheels. His wheels had 40 teeth corresponding to the digits 0 to 9 repeated four times. To get the idea of how they worked, imagine a wheel with only 10 teeth, each with a digit 0-9 in order, next to a tooth. The wheel lays flat and one digit faces you. That digit is the number that the wheel represents. Turn it one place to the left and it represents one digit higher. Turn it a place to the right and it represents one digit lower.

That is fine for numbers between 0 and 9. For larger numbers, just do as we do: use the decimal place system where the value of a digit changes with its position. That first wheel is in the ones row so stands for 0-9. Put a wheel above it in a 10s row and it stands for 10 times the value shown. If a 5 is facing you on that wheel it stands for 50. You can now represent numbers 0 – 99. Put more wheels on top and you can represent hundreds, thousands, and so on.

It’s a neat way of representing numbers using the system we do (though our numbers run right to left not bottom to top). It makes it not only easy for a machine to manipulate the numbers by turning the wheels, but also easy for a human operator to read the numbers. His Difference Engine used several stacks of them, but Babbage envisaged a gigantic room-sized data store of column after column of these number wheels as the memory of his analytical engine, each column storing one potentially very large number.

## A machine that can count

We now have a way to represent numbers but it isn’t yet enough to allow a machine to manipulate them automatically. As it stands it can’t even count properly. We have seen only how to count on one wheel, so only up to 9: every time we turn a crank the 1s wheel turns one notch and so the number represented moves on one. However, we need the other wheels to turn too, but only when the wheel below turns from a 9 to a 0 (so should really become 10). We need a mechanism to carry up to the wheel above. Babbage did this by adding a ridge (a ‘nib’) on the wheel that triggered the carry. When the wheel got to 0, the nib caught against a mechanism above and pushed it, before allowing it to spring back. That nudged the wheel above along one place as required. The 1s wheel was controlled by the crank. The 10s wheel was turned by the 1s wheel moving to 0. The 100s wheel was turned by the 10s wheel moving to 0, and so on. Babbage had a machine that could count!

## A machine that can add

The next problem is how to add numbers stored on wheels. Imagine two wheels, interlocked by their teeth, When one is turned it turns the other the same amount. However if you lift one of the wheels they no longer interlock and move independently.

To do addition, the first wheel is used to hold the number to be added. The second holds the total so far: the answer. That answer wheel starts off set to 0. Now, with the wheels interlocked, turn the first wheel one position at a time counting up to the first number of the addition. It turns the answer wheel exactly the same number of positions transferring the number on to it.

Oops. When cogs interlock, the second wheel turns in the opposite direction to the first! Our machine is subtracting! To make it add, you need a connecting wheel between them. The middle wheel then turns backwards, turning the answer wheel forwards as required. With three wheels like this, any number on the first wheel is added to the answer wheel.

To add a second number, just lift the first wheel to disconnect it, spin it back to zero, drop it back in place and turn it to the second number. The answer wheel then holds the sum of both numbers. If you want to add more numbers, just keep doing this, loading one number at a time onto the first wheel. Each time the total passes 10, the carry mechanism passes the 10 onto the higher wheel and the full decimal total is stored up the stack of wheels.

We have a machine for doing addition!

## A machine that can multiply

Babbage’s machines could multiply as well. How do you do multiplication on wheels? Well, multiplication is just repeated addition. If you want to work out 5 x 3, then it can be calculated as 5 + 5 + 5. So multiplication can simply be done using the adder, adding the same number over and over again. A counter keeps track of how many times to add it. There are faster ways to multiply though. For the Analytical Engine, Babbage designed an efficient table-based multiplier that he was justifiably very proud of.

## Putting it together

Put this together and you have both a number store (a computer memory) and temporary storage areas (registers). You can transfer numbers from one place to another in the machine, and you have the basics of an arithmetic unit that can do calculations. That is about as far as Babbage managed to build. However, he also envisioned programs on punch cards that determined what instruction to execute, mechanisms that allowed instructions to make decisions, and to repeat instructions…everything needed for a general-purpose computer.

Sadly, only parts of his Analytical Engine were ever built, the Victorians did not start the digital age, and we had to wait nearly a century for the first working computers.

## More on …

## Related Magazines …

This article was funded by UKRI, through Professor Ursula Martin’s grant EP/K040251/2 and grant EP/W033615/1.