## Binary

Binary is the *language* of digital electronic communication. Binary is another name for Base2 numbering. Our usual numbering system is Base10, in which a single character or column can represent one of 10 values: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. The first column indicates how many ones there are in a given value. To represent a value greater than 9, we need another column, which represents how many "tens" there are; if the value we want to represent is greater than 99, we use another column for the "hundreds," and so on. You might notice that each additional column is ten times greater than the preceding one: ones, tens, hundreds, thousands, and so forth—all "Powers of 10": 10^{1}, 10^{2}, 10^{3}, and so on. Base10 is easy because most of us have 10 fingers and have known how to count from an early age.

In binary, or Base2, a single character or column can represent one of only two values: 0 or 1. The next column represents how many "twos" there are; the next column how many "fours," and so on. You'll notice here that the value of each additional column is two times greater than the previous—all "Powers of 2": 2^{1}, 2^{2}, 2^{3}, and so on. This is not a coincidence.

Given that a Base2 or binary column can have only two possible values (0 or 1), this makes it easy to represent a binary value as an electrical value: either off (0) or on (1). Computers use binary because it is easily represented as electrical signals in memory or digital values on storage media. The whole system works because computers are quick at computing arithmetic, and as you'll learn, pretty much all computer operations are really just fast binary math.

Let's take a look at some Base10 (or decimal) to binary conversions. Take the decimal number 176. Those three digits tell us that we have one 100, plus seven 10s, plus six 1s. Table 3.1 illustrates how decimal numbers represent this distribution of values.

#### Table 3.1. Decimal Values

100,000s |
10,000s |
1000s |
100s |
10s |
1s |

0 |
0 |
0 |
1 |
7 |
6 |

Notice that we have some zeroes in the high-value columns; we can drop those from the beginning if we want to. You will not have to analyze decimal numbers in this way on the exam; we are simply demonstrating how Base10 works so it can be compared to Base2 and Base16 in the same way.

In binary, the columns have different values—the powers of 2. Table 3.2 lists the values of the lowest eight bits in binary.

#### Table 3.2. Binary Values

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |

To represent the decimal number 176 in binary, we need to figure out which columns (or bit positions) are "on" and which are "off." Now, because this is arithmetic, there are a few different ways to do this.

Start with the decimal number you want to convert:

176

Next, look at the values of each binary bit position and decide if you can subtract the highest column value and end up with a value of 0 or more. Ask yourself: "Can I subtract 128 from 176?" In this case, 176-128 = 48.

Yes, you can subtract 128 from 176 and get a positive value, 48. Because we "used" the 128 column, we put a 1 in that column, as shown in Table 3.3.

#### Table 3.3. Building a Binary String, Part 1

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |

1 |

Now, we try to subtract the next highest column value from the remainder. We get 176 – 128 = 48. We take the 48 and subtract 64 from it.

Notice that you can't do this without getting a negative number; this is not allowed, so we can't use the 64 column. Therefore, we put a 0 in that column, as shown in Table 3.4.

#### Table 3.4. Building a Binary String, Part 2

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |

1 |
0 |

Move along and do the math for the rest of the columns: 48 - 32 = 16. We then subtract 16 from 16 and get 0.

Note that when you get to 0, you are finished—you need to fill the remaining bit positions with 0s to complete the 8-bit string. So, we used only the 128 column, the 32 column, and the 16 column. Table 3.5 is what we end up with.

#### Table 3.5. Completed Binary Conversion

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |

1 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |

176 decimal = 10110000 binary. |

If you add up 128+32+16, you get 176. That is how you convert from binary to decimal: Simply add up the column values where there is a 1.