Digital Logic Design – Number System Conversions

Course Outline  | Previous Lesson

Introduction – Number System Conversions

We are going to learn how to convert from one number system to another. This is an important concept to learn because digital systems operate on binary-number system. However, we are used to using the decimal-number system. Thus, number system conversions are important. We will learn how to convert from decimal to binary, decimal to octal, decimal to hexadecimal, and vice versa.

Division Method

The division method is used to convert decimal numbers to any number system. There are multiple steps to follow for this method.

  1. Choose a decimal number that you want to convert.
  2. Choose a number system that you want to convert to.
  3. Divide the decimal number by the base of a number system you wish to convert to using long division. We do not want fractions when we divide. However, when we cannot divide the numbers equally, we will need to take the remainder. If it does divide equally, the remainder is 0.
  4. Once we find the result after dividing the number, we divide that result by the base of a number system you wish to convert to. We repeat this step until the result gets to zero.
  5. After completing step 4, we should have multiple remainders. The first remainder will represent the least significant place of a number, while the last one represent will represent the most significant place of a number.

Decimal to Binary Conversion

Let us convert number 25 to binary as an example by using the division method. Since binary numbers are base 2, we divide 25 by 2. Please see the table below to see the process of obtaining a binary number.

As you can see above, we use the results and divide them by 2 until the final result is zero. Remember to read the remainder column from bottom to top. The remainders represent bits. The binary number becomes 11001. Therefore, 25_{10} =  11001_{2} .

Decimal to Octal Conversion

Let us convert the decimal number 137 to octal. Remember that octal’s number system is base 8. In this example, we will divide 137 by 8. Please see the table below to see the process of obtaining an octal number.

211_{8} =137_{10}

Decimal to Hexadecimal Conversion

Let us convert the decimal number 223 to hexadecimal. Remember that hexadecimal’s number system is base 16. In this example, we will divide 223 by 16. Also, recall that hexadecimals have 16 unique symbols. Recall that A = 10, B = 11, and etc.

Number 13 is D and number 15 is F in hexadecimal. Thus, 223_{10} = DF_{16}

Power Series Expansion Method

This method is mainly used to convert any number that are not base 10 to a decimal number system.  The power series method uses the positional notation for any number. Recall that 123_{10} = 1\times10^2 + 2\times10^1 + 3\times10^0 . This method can be also be used to convert decimal numbers to other systems. However, that is more complicated. Thus, we are only going to use this method to convert any non-decimal numbers to decimal to make our calculations easier.

Binary to Decimal Conversion

We can convert binary to decimal numbers by using power series expansion. Since binary’s base is 2, we use 2 to multiply each bit. The 2 is also being raised to a power. That represents the bit’s place. When we multiply the whole thing out, we get a decimal number.

11001_{2}=(?)_{10}

11001_{2}  = 1\times2^4 + 1\times2^3 + 0\times2^2 + 0\times2^1 + 1\times2^0

= 16+8+0+0+1 = 25_{10}

Octal to Decimal Conversion

We will convert 211 of base 8 to a decimal number. Thus, the power series expansion will be used for this example.

211_{8} = 2\times8^2 + 1\times8^1 +1\times8^0 \\ \\ = 128+8+1 = 137_{10}

Hexadecimal to Decimal Conversion

We will convert DF of base 16 to a decimal number. Thus, the power series expansion will be used for this example. Recall that D=13 and F=15.

 DF_{16} = 13\times16^1 + 13\times16^0  \\ \\ = 208+15 = 223_{10}

Multiplication Method

This method is an extension to the division method. This method is used for fractional numbers like 0.375, which are numbers to the right of the decimal point. We use this method to convert decimal numbers to other number systems.  Instead of dividing the chosen number by the base of a number system you wish to convert to, we multiply. There are multiple steps to use for this method as well.

  1. Convert the integer part (left part of the decimal point), and write it.
  2. Now, take the fractional part, multiply it by the base of the number system that you wish to convert to.
  3. The result of the multiplication may produce a number with an integer and a fractional part. The integer is like a remainder, so we save that part. That integer represents the converted state of the number from a number system that we want to convert to.
  4. If the result has a fraction, multiply the fractional part by the designated base again and repeat step 3 until we get zero as fraction. Sometimes, we cannot get the fractional part to zero since repeating numbers like 0.333 goes on forever. We stop multiplying before we see a repeating pattern.
  5. Read the result of the integer part from top to bottom (downwards).
  6. Append the integer and fractional part.

There are examples below.

Decimal Fraction  to Binary Fraction

Let us convert decimal number 0.625 to binary. Since we want to convert the number to binary, we are going to multiply 0.625 by 2. Please see the calculations below to learn how to apply the multiplication method.

0.625_{10}=(?)_{2} 

0.625\times2 = 1.250

0.250\times2 = 0.500

0.500\times2 = 1.000

In the last calculation, the fractional part of the result is zero. That means we need to stop multiplying. Now, read each integer part from top to bottom from the right hand side, and that will give us 0.625_{10} =0.101_{2} .

Decimal Fraction to Octal Fraction

Now let us convert decimal number 0.3 to octal. Since we to convert the number to octal, we are going to multiply 0.30 by 8. This example will have a repeating octal number in the fractional portion.

0.30\times8 = 2.40

0.40\times8 = 3.20

0.20\times8 = 1.60

0.60\times8 = 4.80

0.80\times8 = 6.40

As you you can see from the last calculation, the fractional part is 0.40. We have seen that fraction already from the first calculation. If we keep repeating the multiplication, we will have a repeating pattern. It is best to stop at the last calculation above, and read the integer part from top to bottom (downwards). Thus, 0.30_{10} = 0.23146_{8}

Other Base Fraction to Decimal

Converting from a number system to decimal is simple even when fractions are involved. Power series expansion will be used, and this can be extended for numbers with fractional parts.

Octal Fraction to Decimal Fraction

45.352_{8} = 4\times8^1 + 5\times8^0 + 3\times8^{-1} + 5\times8^{-2} +2\times8^{-3} \\ \\ = 32 + 5 + 0.375 + 0.109+0.0039  = 37.457_{10}

Binary Fraction to Decimal Fraction

1001.101_{2} = (?)_{10}

1001.101_{2} = 1\times2^4 +0\times2^3 + 0\times2^2 + 1\times2^1 + 0\times2^0 + \\\\ 1\times2^{-1} +0\times2^{-2} + 1\times2^{-3} = 18.625_{10}

Inter-Conversion Between Bases

Sometimes, we want to convert a number from one non-decimal system to another directly. However, it is generally easier to convert that number to decimal first, and then convert that to the desired number system. Recall that I said that it is harder to use power series method to convert from one non-decimal system to another. Instead, we can use power series to convert the number to decimal, and then use the division method to convert it to a different system like base 3 for an example.

Binary to Base 3

The first thing to do is to convert a binary number to decimal. Furthermore, let us use the binary number 1100 for an example.

1100_{2} = 1\times2^3 + 1\times2^2 + 0\times2^1 + 0\times2^0 \\ \\  = 12_{10}

After we have the decimal number, we will use the division method to convert the number to base 3.

Read the remainder from bottom to top, and it will give you a number from the base 3 system. Thus, 1100_{2} = 110_{3} .

Octal and Hexadecimal Number Systems

Recall from the previous lesson that octal and hexadecimals are used to represent binary numbers in a short-hand notation. We know that one octal symbol represents 3 binary bits, and one hexadecimal symbol represents 4 binary bits.

For an example, converting binary to octal will give us

01100_{2} = 14_{8} . Numbers 01 and 100 represent 1 and 4 in octal respectively even though the first number only has 2 bits since we do not have any more bits to cover.

Here is an hexadecimal example. Converting binary to hexadecimal will give us

01100_{2} = C_{16} . Numbers 0 and 1100 represent 0 and C respectively even though the first number only has 1 bit.

Convert Octal to Hexadecimal and Vice Versa:

It is easier to convert from octal or hexadecimal to binary if we want to convert the number to another system that also represent binary numbers in short-hand notation.

Let us convert the octal number, 110, to hexadecimal. Remember that one octal symbol represents 3 bits. We know that octal 1 is 001 and 0 is 000. So that means the number is 001001000 in binary. To convert it to hexadecimal, we need to group up four bits that make up one hexadecimal symbol. The hexadecimal turns out to be 48. In addition, we can ignore the leading zeroes of the number. The number 048 is the same as 48.

Let us convert the hexadecimal number, AF, to octal. Remember that one hexadecimal symbol represents 4 bits in binary. We know that A = 1010 and F = 1111. Thus, AF = 10101111. One octal symbol represents 3 bits. As a result, AF = 257.

Conclusion

Number system conversions are important since it is necessary to learn to convert from one number system to another. We learned how to convert from decimal numbers to another systems, and vice versa by using the division and power series expansion. In addition, we used the multiplication method to convert fractional, decimal numbers to other systems. Also, we learned to use both methods to convert numbers from non-decimal systems to another. Finally, we learned how to convert from octal to hexadecimal systems and vice versa.

 

Course Outline  | Previous Lesson

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz