CONVERSION OF BASES
We mentioned in the introduction to this chapter that digital computers operate on electrical pulses. These pulses or the absence of, are easily represented by binary numbers. A pulse can represent a binary 1, and the lack of a pulse can represent a binary 0 or vice versa.
The sections of this chapter that discussed octal and hex numbers both mentioned that their number systems were beneficial to programmers. You will see later in this section that octal and hex numbers are easily converted to binary numbers and vice versa.
If you are going to work with computers, there will be many times when it will be necessary to convert decimal numbers to binary, octal, and hex numbers. You will also have to be able to convert binary, octal, and hex numbers to decimal numbers. Converting each number system to each of the others will be explained. This will prepare you for converting from any base to any other base when needed.
Some computer systems have the capability to convert decimal numbers to binary numbers. They do this by using additional circuitry. Many of these systems require that the decimal numbers be converted to another form before entry.
Decimal to Binary
Conversion of a decimal number to any other base is accomplished by dividing the decimal number by the radix of the system you are converting to. The following definitions identify the basic terms used in division:
QUOTIENT - The number resulting from the division of one number by another REMAINDER - The final undivided part after division that is less or of a lower degree than the divisor
To convert a base 10 whole number to its binary equivalent, first set up the problem for division:
Step 1 - Divide the base 10 number by the radix (2) of the binary system and extract the remainder (this becomes the binary number's LSD).
Step 2 - Continue the division by dividing the quotient of step 1 by the radix (2 / 2).
Step 3 - Continue dividing quotients by the radix until the quotient becomes smaller that the divisor; then do one more division. The remainder is our MSD.
The remainder in step 1 is our LSD. Now rewrite the solution, and you will see that 510 equals 1012. Now follow the conversion of 2310 to binary:
Step 1 - Set up the problem for division:
Step 2 - Divide the number and extract the remainder:
Step 3 - Rewrite the solution from MSD to LSD:
No matter how large the decimal number may be, we use the same procedure. Let's try the problem below. It has a larger dividend:
We can convert fractional decimal numbers by multiplying the fraction by the radix and extracting the portion of the product to the left of the radix point. Continue to multiply the fractional portion of the previous product until the desired degree of accuracy is attained.
Let's go through this process and convert 0.2510 to its binary equivalent:
The first figure to the left of the radix point is the MSD, and the last figure of the computation is the LSD. Rewrite the solution from MSD to LSD preceded by the radix point as shown:
Now try converting .62510 to binary:
As we mentioned before, you should continue the operations until you reach the desired accuracy. For example, convert .42510 to five places in the binary system:
Although the multiplication was carried out for seven places, you would only use what is required. Write out the solution as shown:
To convert a mixed number such as 37.62510 to binary, split the number into its whole and fractional components and solve each one separately. In this problem carry the fractional part to four places. When the conversion of each is completed, recombine it with the radix point as shown below:
Convert the following decimal numbers to binary: