# Decoding Binary

Today you are going to learn how to convert 110101110010101101001001 to a decimal number. No seriously, we are.

Can you say hacker status? It’s going to be awesome. Just wait!

### Welcome to the World of Binary!

Yes, the computer hacker stuff you see on tv, and just to clear the record: no, programmers don’t really write code in binary nor do they stare at binary numbers all day.

In fact, they rarely need to use binary numbers. But nonetheless, they are a foundational aspect of computer science that pop up here and there and are a fun application of base systems!

Who wants to guess what base binary is?

hint: remember base refers to the number of symbols in the system.

Two. Binary is the base two number system. Therefore, we express it using two symbols, 0 and 1. Binary follows the same exponential pattern we discovered with the decimal system, except of course instead of powers of 10 we will use powers of 2.

For example, here is a random binary number.

I simply replaced the ten’s with two’s and we now have a binary place-value system! Of course, we no longer can refer to the place-values as ones, tens, hundreds, … because that’s decimal. We must rename them.

Let’s calculate these first five place-values to find out their names.

It may seem strange, but the place-value names for the first five binary place-values are: one’s, two’s, four’s, eight’s and sixteen’s place.

### Example 1

Let’s convert the above binary number 11001.

First write out a binary expansion to figure out what this number would be in decimal. Remember a “1” means we have the number in the place-value, a “0” means we do not.

The binary number 11001 means we have 1 one, 1 eight and 1 sixteen. Now add them up. Hence, 11001 = 25.

### Example 2

Let’s try a larger number. How about 1010101?

Step 1: Think about the binary place-value system.

Step 2: Calculate each column’s value.

Nice work, you just figured out that 1010101 = 85.

### Challenge Problem

Now go back to that monstrosity I wrote on the first line of this post and calculate its value in decimal!

### Example 3

Can you convert the decimal number 9 into binary?

To solve this problem you need to think about the largest power of 2 that is less than 9. Let’s look at the binary place-value system to aid us.

It looks like 8 is the largest number less than 9, so place a 1 in the eight’s column.

We still need 1 more unit to make 9, so place a 1 in the one’s place-value.

Fill in the other places with zeros. We needn’t fill in any columns to the left of the eight’s column since that is the largest place-value in use.

Therefore, 9 = 1001 in binary.

### Example 4

Let’s convert 42 into binary.

Step 1: What is the largest binary place-value that is less than 42? Looks like it is 32, so place a 1 in the 32 column.

Step 2: Subtract 32 from 42, and we are left with 10. So repeat the process with 10. What is the largest power of two less than 10?

Eight. So place a 1 in the eight’s column.

Step 3: Subtract 8 from 10, and we are left with 2. So lastly, place a 1 in the two’s column.

Step 4: Fill in the necessary zeros.

Hence the secret to life, the universe and everything else, in binary, is 101010, obviously.

Next Lesson: Math as Mental Weight Lifting & A King’s Dilemma