Digital Logic Design – Number System Conversions
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.
The division method is used to convert decimal numbers to any number system. There are multiple steps to follow for this method.
- Choose a decimal number that you want to convert.
- Choose a number system that you want to convert to.
- 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.
- 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.
- 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, .
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.
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,
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 . 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.
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.
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.
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.
- Convert the integer part (left part of the decimal point), and write it.
- Now, take the fractional part, multiply it by the base of the number system that you wish to convert to.
- 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.
- 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.
- Read the result of the integer part from top to bottom (downwards).
- 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.
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 .
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.
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,
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
Binary Fraction to Decimal Fraction
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.
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, .
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
. 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
. 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.
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.