# Binary system math

To determine the value of a digit, count the number of digits to the left of it, and multiply that number times 2. For example, for the digital number , to determine the value of the 1, count the number of digits to the left of the 1 and multiply that number times 2. The total value of binary is 4, since the numbers to the left of the 1 are both 0s. Now you know how to count digital numbers, but how do you add and subtract them?

Binary math is similar to decimal math. Adding binary numbers looks like that in the box to the right above. To add these binary numbers, do this: Start from the right side, just as in ordinary math. Write a 1 down in the solution area. According to our rule, that equals 0, so write 0 and carry the 1 to the next column. Any time you have a column that adds up to decimal 3, you write down a 1 in the solution area and carry a 1.

In the fifth column you have only the 1 that you carried over, so you write down 1 in the fifth column of the solution. Computers rely on binary numbers and binary math because it greatly simplifies their tasks. Since there are only two possibilities 0 and 1 for each digit rather than 10, it is easier to store or manipulate the numbers. Computers need a large number of transistors to accomplish all this, but it is still easier and less expensive to do things with binary numbers rather than decimal numbers.

The original computers were used primarily as calculators, but later they were used to manipulate other forms of information, such as words and pictures. In each case, engineers and programmers sat down and decided how they were going to represent a new type of information in binary form. The chart shows the most popular way to translate the alphabet into binary numbers only the first six letters are shown. This process continues until we have a remainder of 0. Let's take a look at how it works.

To convert the decimal number 75 to binary, we would find the largest power of 2 less than 75, which is Subtract 8 from 11 to get 3. Thus, our number is Making this algorithm a bit more formal gives us: Find the largest power of two in D. Let this equal P. Put a 1 in binary column P. Subtract P from D. Put zeros in all columns which don't have ones.

This algorithm is a bit awkward. Particularly step 3, "filling in the zeros. Now that we have an algorithm, we can use it to convert numbers from decimal to binary relatively painlessly. Our first step is to find P. Subtracting leaves us with Subtracting 1 from P gives us 4.

Next, subtract 16 from 23, to get 7. Subtract 1 from P gives us 3. Subtract 1 from P to get 1. Subtract 1 from P to get 0. Subtract 1 from P to get P is now less than zero, so we stop. Another algorithm for converting decimal to binary However, this is not the only approach possible. We can start at the right, rather than the left. This gives us the rightmost digit as a starting point.

Now we need to do the remaining digits. One idea is to "shift" them. It is also easy to see that multiplying and dividing by 2 shifts everything by one column: Similarly, multiplying by 2 shifts in the other direction: Take the number Dividing by 2 gives Since we divided the number by two, we "took out" one power of two. Also note that a1 is essentially "remultiplied" by two just by putting it in front of a[0], so it is automatically fit into the correct column.

Now we can subtract 1 from 81 to see what remainder we still must place Dividing 80 by 2 gives We can divide by two again to get This is even, so we put a 0 in the 8's column. Since we already knew how to convert from binary to decimal, we can easily verify our result. These techniques work well for non-negative integers, but how do we indicate negative numbers in the binary system? Before we investigate negative numbers, we note that the computer uses a fixed number of "bits" or binary digits.

An 8-bit number is 8 digits long.