Counting in binary number system
Thus, the answer is Binary addition works on the same principle, but the numerals are different. Begin with one-bit binary addition:. In binary, any digit higher than 1 puts us a column to the left as would 10 in decimal notation. Record the 0 in the ones column, and carry the 1 to the twos column to get an answer of " The process is the same for multiple-bit binary numbers: Record the 0, carry the 1.
Add 1 from carry: Multiplication in the binary system works the same way as in the decimal system: Follow the same rules as in decimal division.
For the sake of simplicity, throw away the remainder. Converting from decimal to binary notation is slightly more difficult conceptually, but can easily be done once you know how through the use of algorithms. Begin by thinking of a few examples. Almost as intuitive is the number 5: Then we just put this into columns.
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. The third digit can equal 4 or 0. The fourth digit can equal 8 or 0. If you write down the decimal values of each of the digits and then add them up, you have the decimal value of the binary number.
In the case of binary 11, there is a 1 in the first position, which equals 1 and then another 1 in the second position, so that equals 2. As numbers get larger, new digits are added to the left. 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: 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, 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. For this section, we will work with 8 bits. The simplest way to indicate negation is signed magnitude. To indicate , we would simply put a "1" rather than a "0" as the first bit: In one's complement, positive numbers are represented as usual in regular binary.
However, negative numbers are represented differently. To negate a number, replace all zeros with ones, and ones with zeros - flip the bits. Thus, 12 would be , and would be As in signed magnitude, the leftmost bit indicates the sign 1 is negative, 0 is positive. To compute the value of a negative number, flip the bits and translate as before. Begin with the number in one's complement. Add 1 if the number is negative. Twelve would be represented as , and as