Before you start reading this article, I want you to take a trip back into your past when you were being taught the decimal system. Personally, when I was in elementary school (in the 70′s/80′s), teachers used to use a column system to teach us about numbers:
[Thousands] | [Hundreds] | [Tens] | [One]
The number 1234 is – 1 Thousands, 2 Hundreds, 3 Tens and 4 Ones.
A few years later, we learned about the composition of the decimal system in a more complex way.
Thousands became 10^3 (10*10*10)
Hundreds became 10^2 (10*10)
… and so on.
1234 then became:
As you already know, counting in decimals is done by using 10 digits, from 0 to 9. Each time we jump a “column” (from 9 to 10), we add 1 digit to our total and reset all subsequent numbers to 0 (999 becomes 1000). The binary system works exactly the same way, but instead of using digits that goes from 0 to 9, we keep things simple and only use 0′s and 1′s, just like computers do. But the question you are probably asking yourself now is why do computers only use 0′s and 1′s? The answer is simple: electronic circuits. Circuits that make the wheel inside your computer turn can only have 2 states, on and off. Since a computer is mostly made out of electronic circuitry, it is logical that it uses the binary system to send, receive or compute information.
How does the binary system work?
Let’s start with what a binary number looks like:
“What the heck does this mean, and how do I represent this in more familiar decimal format” you ask. First, you have to know that each digit of a binary number is based on 2 to the power of x (as opposed to the decimal system that is based on the number 10). Here is a quick and easy chart you should study before continuing:
2 to the power of 0 = 1 (2^0)
2 to the power of 1 = 2 (2^1)
2 to the power of 2 = 4 (2^2) or (2*2)
2 to the power of 3 = 8 (2^3) or (2*2*2)
2 to the power of 4 = 16 (2^4) or (etc.)
2 to the power of 5 = 32 (2^5)
2 to the power of 6 = 64 (2^6)
2 to the power of 7 = 128 (2^7)
2 to the power of 8 = 256 (2^8)
2 to the power of x = (2^x)
Ok, let’s apply this chart to the binary number I gave a few moments ago to get us the decimal equivalent. All digits that are 0 remain 0, and are only useful as position placeholders. All digits that are assigned a value of 1 have a decimal value that is equal to the power (2^x) of their position within the chart.
128 64 32 16 8 4 2 1
0 1 0 0 1 0 1 0
01001010 = 64 + 8 + 2
which means that 01001010 = 74
Simple isn’t it?
Now let’s do the inverse. To convert 74 to binary, you’ll have to start by finding the biggest power of 2 that is valued less then 74. Finding this number is important because it will determine the positive value at the left of your binary number. In this case, it is 64.
Let’s put a 1 in the 2^6 (2*2*2*2*2*2 = 64) position.
After, take your initial decimal number, and subtract it by the value you just found out. 74 – 64 = 10. Now, let’s do the same procedure as before. What is the biggest power of 2 that is valued less then 10? It is 8.
Put a 1 in the 2^3 position ( 2*2*2 = 8 )
…and continue doing this until the total equals your initial decimal number.
Even numbers always finish with a 0 and odd ones end in 1. This is because the rightmost digit in a binary number can only have a decimal value of 0 or 1.
As a non-IT person, there’s no real reason why you should know about how to do this manually, except to sound smart in front of your peers. Most modern calculators (including the windows one) can also accomplish these operations quickly and painlessly.
So why bother with all this? The answer is simple: Because you’re a geek (or an aspiring one)!