# Portal:AOL-Files/Articles/Binary Tutorial

(Originally by AOL-Files staff member Tau)

Editor's note: This is without a doubt the most obscenely, disgustingly complex way to convert a number to binary I've ever seen. A quick web search will show you extremely simple ways to do it with a line chart or via hexadecimal. I suggest not reading any further, lest it make you think it's more complicated than it really is.

Numbers that we use everyday have a base of 10 which means that there are ten numbers used: 0,1,2,3,4,5,6,7,8, and 9. These 10 numbers without the help of any other symbols can be rearranged to describe any positive integer. Binary however, has a base 2 which means that there are only 2 number used (0 and 1). These too can be arranged to form any positive integer.

Undoubtedly you have seen commercials and backgrounds of web pages with binary on it. When seeing these commercials most people know that the 0s and 1s have to do with computers but have absolutely no idea how and I have a feeling the people who make the TV ads don't know how to utilize binary correctly either.

In this tutorial you will learn how to convert base 10 numbers into binary and how to convert binary into base 10. To make things more simple, I will refer to base 10 numbers just as "numbers" and base 2 numbers as binary.

## Converting into Binary

Binary conversion is based on powers of 2:

• 2^0 = 1
• 2^1 = 2
• 2^2 = 4
• 2^3 = 8
• 2^4 = 16
• 2^5 = 32
• 2^6 = 64
• 2^7 = 128

We will begin by converting numbers and later it will be seen that you can convert letters and other characters into binary. Binary is mainly used with computers to convert a byte(a number from 0 to 255) into an eight digit string of 0s and 1s. Get a paper and a pencil and pick any number between 0 and 255. As you are converting write the digits and you move along.

These are the steps of how you would convert it into binary:

• If 128 is greater than your number then the first digit of your binary conversion is 0.
• If 128 is less than your number then the first digit of your binary conversion is 1. Now subtract 128 from your number. The resulting number will be used in the following step.
• If 128 is the number then you will use a 1 and all you need to do now is add the rest of the zeros to make 8 digits. Then your done.

### 2. Now you will use 2^6(64)

Remember: If you subtracted 128 in the previous step you will use the new resulting number.

• If 64 is greater than your number then the second digit of your binary conversion is 0.
• If 64 is less than your number then the second digit of you binary conversion is 1. Now subtract 64 from your number. The resulting number will be used in the following step.
• If 64 is the number then you will use a 1. All the remaining digits automatically are 0.

### 3. Now you will use 2^5(32)

Remember: If you subtracted 64 in the previous step you will use the new resulting number.

• If 32 is greater than your number then the third digit of your binary conversion is 0.
• If 32 is less than your number then the third digit of you binary conversion is 1. Now subtract 32 from your number. The resulting number will be used in the following step.
• If 32 is the number then you will use a 1. All the remaining digits are 0.

### 4. Now you will use 2^4(16)

Remember: If you subtracted 32 in the previous step you will use the new resulting number.

• If 16 is greater than your number then the fourth digit of your binary conversion is 0.
• If 16 is less than your number then the fourth digit of you binary conversion is 1. Now subtract 16 from your number. The resulting number will be used in the following step.
• If 16 is the number then you will use a 1. All the remaining digits are 0.

### 5. Now you will use 2^3(8)

Remember: If you subtracted 16 in the previous step you will use the new resulting number.

• If 8 is greater than your number then the fifth digit of your binary conversion is 0.
• If 8 is less than your number then the fifth digit of you binary conversion is 1. Now subtract 8 from your number. The resulting number will be used in the following step.
• If 8 is the number then you will use a 1. All the remaining digits are 0.

### 6. Now you will use 2^2(4)

Remember: If you subtracted 8 in the previous step you will use the new resulting number.

• If 4 is greater than your number then the sixth digit of your binary conversion is 0.
• If 4 is less than your number then the sixth digit of you binary conversion is 1. Now subtract 4 from your number. The resulting number will be used in the following step.
• If 4 is the number then you will use a 1. All the remaining digits are 0.

### 7. Now you will use 2^1(2)

Remember: If you subtracted 4 in the previous step you will use the new resulting number.

• If 2 is greater than your number then the seventh digit of your binary conversion is 0.
• If 2 is less than your number then the seventh digit of you binary conversion is 1. Now subtract 2 from your number. The resulting number will be used in the following step.
• If 2 is the number then you will use a 1. All the remaining digits are 0.

### 8. Now you will use 2^0(1)

Remember: If you subtracted 2 in the previous step you will use the new resulting number.

• If 1 is greater than your number then the eighth digit of your binary conversion is 0.
• If 1 is less than your number then the eighth digit of you binary conversion is 1. Now subtract 1 from your number.
• If 1 is the number then you will use a 1. All the remaining digits are 0.

## Examples

Now lets apply these steps to converting numbers. Since binary is eight digits long we will use x's as place holders while converting.

### Converting the number 159

1. 128 < 159. So we will use a 1. Subtract 128 from 159 resulting with 31. Currently we have 1xxxxxxx.
2. 64 > 31. So we will use a 0. We now have 10xxxxxx.
3. 32 > 31. So we will use a 0. We now have 100xxxxx.
4. 16 < 31. So we will use a 1. Subtract 16 from 31 resulting in 15. We now have 1001xxxx.
5. 8 < 15. So we will use a 1. Subtract 8 from 15 resulting in 7. We now have 10011xxx.
6. 4 < 7. So we will use a 1. Subtract 4 from 7 resulting in 3. We now have 100111xx.
7. 2 < 3. So will use a 1. Subtract 2 from 3 resulting in 1. We now have 1001111x.
8. 1 = 1. So we will use a 1. Subtract 1 from 1 resulting in 0. We now have 10011111.

So the binary conversion of 159 is 10011111.

### Converting the number 202

1. 128 < 202. So we will use a 1. Subtract 128 from 202 resulting with 74. Currently we have 1xxxxxxx.
2. 64 < 74. So we will use a 1. Subtract 64 from 74 resulting in 10. We now have 11xxxxxx.
3. 32 > 10. So we will use a 0. We now have 110xxxxx.
4. 16 > 10. So we will use a 0. We now have 1100xxxx.
5. 8 < 10. So we will use a 1. Subtract 8 from 10 resulting in 2. We now have 11001xxx.
6. 4 > 2. So we will use a 0. We now have 100110xx.
7. 2 = 2. So will use a 1. Subtract 2 from 2 resulting in 0. We now have 1100101x.
8. We have already reached 0 so all the remaining digits will be 0. We now have 11001010.

So the binary conversion of 202 is 11001010.

### Converting the number 47

1. 128 > 47. So we will use a 0. Currently we have 0xxxxxxx.
2. 64 > 47. So we will use a 0. We now have 00xxxxxx.
3. 32 < 47. So we will use a 1. Subtract 32 from 47 resulting in 15. We now have 001xxxxx.
4. 16 > 15. So we will use a 0. We now have 0010xxxx.
5. 8 < 15. So we will use a 1. Subtract 8 from 15 resulting in 7. We now have 00101xxx.
6. 4 < 7. So we will use a 1. Subtract 4 from 7 resulting in 3. We now have 001011xx.
7. 2 < 3. So will use a 1. Subtract 2 from 3 resulting in 1. We now have 0010111x.
8. 1 = 1. So we will use a 1. We now have 00101111

So the binary conversion of 47 is 00101111.

## Converting out of Binary

Fortunately for us, converting out of binary is much simpler than converting into binary.

First, make a table like the one below. In this example we are going to convert out of 11001010.

 1 64 0 32 0 16 1 8 0 4 1 2 0 1

As you can see, I have made the binary digit by digit in the first colomn in the first rows. In the second column I have listed the powers of 2 in reverse order starting with 2^7. Now, look at each row and decide whether the number is a 0 or a 1. If it is a 1 then check the third box in that row.

After you have check all of the rows with 1's add the powers of 2s that are in the checked boxes.

128+64+8+2=202. Now if you check the second binary conversion example you will see that this is the correct answer.

## ASCII

So what practical application does this have?

Knowing the numerical value of letters allows you to convert letters into numbers, then into binary.

For example, if you wanted to know the binary for "T" you would look at the list and see that it is 84. Then you can convert 84 into binary.

Now, you can convert words and sentences into binary.

"cat" would be ASCII characters 99, 97, and 116:

Convert these into binary to get 01100011, 01100001, and 01110100. So "cat" converted into binary would be the combination of these three: 011000110110000101110100. To decode 011000110110000101110100 just separate it back into groups of 8 then convert back.

You can encode secret messages with this among other things. Also, knowing how to convert into and out of binary is something to brag about.