Computers only translate the presence of electricity in their circuits. The presence of an electric current in a circuit is represented by a 1, and the absence of electricity is represented with a 0. Since computers can only translate two different states, they use base 2 counting system to count and represent numbers and information.
We people use base 10 to count (probably because we have 10 fingers). We have 10 digits we use to count: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. In base two, there is only 0 and 1. Here’s how counting in our base 10 system works. We have a 1’s place, a 10’s place, and so on, going up and up in powers of 10s.
10^0 = 1 //One's place
10^1 = 10 //Ten's place
10^2 = 100 //Hundred's place
So if we have the number 5402, we have 5 thousands, 4 hundreds, 0 tens, and 2 ones. Now let’s try this with base 2. It‘s like base 10, only it works in powers of 2. Naturally, it will take a lot more digits to represent values than base 10 representations would because the powers of 2 are much smaller than the powers of 10.
Here’s the table of how binary digits work:
2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
//All these numbers added together is 255.
Remember that any number to the 0th power is 1! This is important to remember. The first place at the right will ALWAYS be the 1’s place, and you’ll work to the left in powers of the base you’re using from there.
This might clarify why any number to the 0th power is 1.
2^3 = 8
2^2 = 4
2^1 = 2
2^0 = 1
2^-1 = 1/2
2^-2 = 1/4
2^-3 = 1/8
As you work from the right side of the table to the left, you see that the values of the powers are always being divided by two. 8/2 = 4. 4/2 = 2. And so, 2/2 = 1. 1 divided by two is 1/2, and divide that by two again, and you get 1/4.
Let’s try converting the number 170 to binary code. To do this, we start from the left side of the table, to the right. We find the greatest number that will go into 170 ONCE and only ONCE. 128 can go into 170 once, so we place a 1 for our first digit. We then take the remainder, which is 42, and move it to the next column. Does 64 go into 42? No. So we place a 0 in that column. Let’s move on and try 32. 32 can go into 42, so we can place a 1 there, which leaves us only 10. Moving on, 16 cannot go into 10 so a 0 is placed there. 8 goes into 10, and we place a 1 there, leaving us with only 2 for the twos column.
Our resulting number is 1010 1010