# Let’s Build a Computer #1 (Binary Numbers)

No account yet? Register

In this series you will learn how computers work from the ground up. You will learn by actually building it piece by piece (on paper) in a series of weekly articles. If you continue and follow along, you will fully understand how a modern computer operates down to the smallest detail!

Let’s Start!

Computers only understand numbers, so we need to come up with a way of representing them. Since computers are built using only on/off switches, we need to use something very simple. Computer designers came up with a number system called Binary.

Our computer will be very basic and just handle the numbers 0 through 7. However, the same concept can be expanded to handle any number. The binary code scientists came up with to count is as follows and uses base 2 (0-1 digits) instead of base 10 (0-9 digits) concepts. Don’t worry if that confuses you now. You will understand it later by doing examples.

One way to visualize it is to pretend you were an alien on another planet who did not understand anything except the number ‘0’ and ‘1’, but needed a way to count things. The system below would give you that ability.

Binary Numbers 0 – 7

• 000 = 0
• 001 = 1
• 010 = 2
• 011 = 3
• 100 = 4
• 101 = 5
• 110 = 6
• 111 = 7

Take a minute to see if you can discover the pattern. The first column multiplies by 4, the second by 2, and the first by 1. In mathematical terms, it is all based on powers of 2, like 2^0=1, 2^1=2, and 2^2=4. If we added another column to handle 4 digit binaries, it would be 2^3 = 8. We can represent an infinite amount of numbers using this system.

The number 5 is 101 in binary. This is the same as= 1×4 + 0x2 + 1×1 = 4 + 0 + 1 = 5

It may look very strange, but you do this all the time without realizing it using normal math and base 10. Example: 25 = 2×10 + 5×1 = 25

Here is a video that talks about converting decimals numbers to binary with more details. However, if you have faith in the 0-7 binary list above, it is good enough to continue our computer journey.

## Binary Math

Now that we have a way to represent numbers with 1’s and 0’s, we need a way to do math on them. Let’s start by adding, which is actually very simple and works like the way you add normal numbers, except you can’t go higher than 1.

If you want to add 1 + 2 in binary, you first need to convert the numbers to binary (you can just use our list):
1 = 001
2 = 010

001 +
010
——-
011

You add it like normal numbers. The answer is 011 which translates to 3 in human readable form.

Here is a more advanced one: 3 + 3
3 = 011

011 +
011
——
???

Just like normal addition, we start on the right side: 1 + 1 = 2. We know 2 = ‘010’ in binary, so we put down the 0 and carry the 1. This is similar to how you can only go up to 9 with regular numbers (base 10) and carry the 10’s place if the number is over 9.

110
011 +
011
—–
110

The middle column now adds up to 3. We can represents this as “011” in binary and need to put down a ‘1’ and carry the ‘1’ over.

We now have 110 = 4×1 + 2×1 + 1×0 = 4 + 2 + 0 = 6, which is the correct answer when converted to our normal base 10 system. Here is another way of looking at it (Source: Carrying Binary Digits).

Below is a good video to review binary addition. You really need to understand this concept well before we can move on and actually build the hardware that will add numbers for us. It is one the most important parts of a computer.

Take some time to understand binary numbers and adding them. Next week we will start building our computer adder, or ALU (Arithmetic Logic Unit) that will perform math for us. The good news is that you don’t need to understand any more math. This is the most complex it gets. Computers only know how to add. We will talk about subtraction, multiplication, and division later, but it is just done using binary addition and some special tricks!

If you have any questions, please comment below. I look forward to taking you on this wonderful journey to understand how computers really work.