Digital Electronics - Base Conversions



In the previous chapter, we explained the different types of number systems used in digital electronics. In this chapter, we will explain how you can convert a number from one base to another.

What is Number System Conversion?

Number system conversion is a process of converting a number from one base to another. Number system conversion is an important concept to represent information in different forms. In digital electronics, the following number system conversions are mostly performed.

  • Binary to Decimal Conversion
  • Decimal to Binary Conversion
  • Binary to Octal Conversion
  • Octal to Binary Conversion
  • Octal to Decimal Conversion
  • Decimal to Octal Conversion
  • Hexadecimal to Binary Conversion
  • Binary to Hexadecimal Conversion
  • Hexadecimal to Decimal Conversion
  • Decimal to Hexadecimal Conversion
  • Octal to Hexadecimal Conversion
  • Hexadecimal to Octal Conversion

Let us understand each of these number system conversions with the help of examples.

Binary to Decimal Conversion

We can convert a binary number into its equivalent decimal number by using the positional weights method.

In this method of binary to decimal conversion, each digit of the given binary number is multiplied by its positional weight. Then, all the products are added to obtain the equivalent decimal number.

The step-by-step process of converting a binary number to its equivalent decimal number by using positional weights method is explained below −

Step 1 − Write the positional weights for each binary digit.

Step 2 − Multiply each binary digit with its positional weight.

Step 3 − Add the product terms to obtain the equivalent decimal number.

Let us consider some examples to understand the binary to decimal conversion.

Example 1

Convert (101101)2 into decimal equivalent.

Solution

The given binary number is (101101)2

Step 1 − Defining positional weights for the given binary number −

Bits 1 0 1 1 0 1
Weights 25 24 23 22 21 20

Step 2 − Calculating product of bits and positional weights −

Bits Weights Multiply Product
1 25 1 × 32 32
0 24 0 × 16 0
1 23 1 × 8 8
1 22 1 × 4 4
0 21 0 × 2 0
1 20 1 × 1 1

Step 3 − Add all the product terms to obtain the equivalent decimal number −

Decimal Number = 32 + 0 + 8 + 4 + 0 + 1 = (45)10

Hence, the decimal equivalent of (101101)2 is (45)10.

Example 2

Convert (1111011)2 into decimal equivalent.

Solution

Multiplying Bits with positional weights, we get,

Decimal Number = 1 × 26 + 1 × 25 + 1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20

Decimal Number = 64 + 32 + 16 + 8 + 0 + 2 + 1 = (123)10

Hence, the decimal equivalent of (1111011)2 is (123)10.

Example 3

Convert (1001.11)2 into decimal.

Solution

The given binary number has integer and fractional parts. The integer part is multiplied with positive weights, while the fractional part is multiplied with negative weights as follows −

Decimal Number = 1 × 23 + 0 × 22 + 0 × 21 + 1 × 20 + 1 × 2-1 + 1 × 2-2

Decimal Number = 8 + 0 + 0 + 1 + 0.5 + 0.25 = (9.75)10

Thus, the decimal equivalent of (1001.11)2 is (9.75)10.

Decimal to Binary Conversion

A decimal number can be converted to their equivalent binary number by using the double-dabble method. In this method, the integer part of the given decimal number is successively divided by 2 and the fractional part is successively multiplied by 2.

In the integer part, the remainders read from bottom to top give the integer part of the binary equivalent. In the fractional part, the carries read from top to bottom give the fractional part of the binary equivalent.

The following steps are followed to convert a decimal number to the binary equivalent −

Step 1 − Divide the integer part of the given decimal number successively by 2 and read the remainders from bottom to top.

Step 2 − Multiply the fractional part of the given decimal number successively by 2 and read the carries from top to bottom.

Let us see some examples to understand the conversion of a decimal number into its equivalent binary number.

Example 1

Convert (28)10 to binary equivalent.

Solution

The given decimal number is an integer. Thus, we divide the decimal number successively by 2 and read the remainders upwards to obtain the equivalent binary number.

Decimal Remainders
2 28
2 14 0
2 7 0
2 3 1
2 1 1
0 1

Reading the remainders from bottom to top, the result will be (11100)2. It is the binary equivalent of (28)10.

Example 2

Convert (165.75)10 to its equivalent binary.

Solution

The given decimal number is a mixed number having both integer and fractional parts. Thus, to obtain its equivalent binary number, we convert the integer and fractional parts separately.

The binary equivalent of 16510 is obtained as follows,

Decimal Remainders
2 165
2 82 1
2 41 0
2 20 1
2 10 0
2 5 0
2 2 1
2 1 0
0 1

Reading the remainders from bottom to top, the binary equivalent of 16510 is (10100101)2.

Now, let's convert the Fractional Part (0.75) of the given number.

To convert the given decimal fraction into binary, we multiply it by 2, as follows,

Decimal Product Carry
0.75 × 2 1.5 1
0.5 × 2 1.0 1
0 × 2 0

Reading the carries from top to bottom, the result is 0.11. Thus, the binary equivalent of (0.75)10 is (0.11)2.

Therefore, (165.75)10 = (10100101.11)2

Binary to Octal Conversion

A binary number can be converted into its equivalent octal number by mapping method. The conversion of a binary number to the octal equivalent is done as per the following steps −

Step 1 − Starting from the binary point, make groups of 3-bits on both sides of the binary point.

Step 2 − Replace each group of 3-bit binary by the equivalent octal digit.

The following table shows the equivalent octal digital for each 3-bit binary group −

Octal Binary
(2)2 = 4 (2)1 = 2 (2)0 = 1
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1

Let us understand the binary to octal conversion with the help of examples.

Example 1

Convert (110011101.110101)2 to its octal equivalent.

Solution

The binary to octal conversion will be performed as follows −

3-bit Group 110 011 101 . 110 101
Octal Equivalent 6 3 5 . 6 5

Hence, the octal equivalent of given binary number is (635.65)8.

Example 2

Convert (1110111011.11101)2 to octal equivalent.

Solution

The conversion of given binary number to octal number is given below −

3-bit Group 1 110 111 011 . 111 01
011 110 111 011 . 111 010
Octal Equivalent 3 6 7 3 . 7 2

Hence, the octal equivalent of (1110111011.11101)2 is (3673.72)8.

Octal to Binary Conversion

We can also use the mapping method to convert an octal number into its equivalent binary number. In this method, we just replace each digital of the given octal number by its 3-bit binary equivalent.

Let’s understand the conversion of octal number to binary equivalent with the help of examples.

Example 1

Convert (3572.126)8 to binary equivalent.

Solution

The given octal number is converted into binary equivalent as follows −

Octal Number 3 5 7 2 . 1 2 6
3-bit Binary Equivalent 011 101 111 010 . 001 010 110

Hence, the binary equivalent of (3572.126)8 is (011101111010.001010110)2.

Example 2

Convert (364.52)8 to its binary equivalent.

Solution

The conversion of given octal number to its equivalent binary number is given below −

Octal Number 3 6 4 . 5 2
3-bit Binary Equivalent 011 110 100 . 101 010

Thus, the binary equivalent of the octal number (364.52)8 is (011110100.101010)2.

Octal to Decimal Conversion

The conversion of an octal number to its equivalent decimal number is same as the binary to decimal conversion. To convert an octal number to its decimal equivalent, we multiply each digit of the octal number by its positional weight and then add all the product terms to obtain the equivalent decimal number.

The step-by-step procedure to convert an octal number to its equivalent decimal number is given below −

Step 1 − Write the positional weights for each octal digit.

Step 2 − Multiply each octal digit with its positional weight.

Step 3 − Add the product terms to obtain the equivalent decimal number.

Let us understand the conversion of octal number to decimal number with the help of examples.

Example 1

Convert (356.25)8 to its decimal equivalent.

Solution

The given octal number can be converted to equivalent decimal number as follows −

Octal Digits Positional Weights Multiply Product
3 (8)2 3 × (8)2 192
5 (8)1 5 × (8)1 40
6 (8)0 6 × (8)0 6
. . . .
2 (8)-1 2 × (8)-1 0.25
5 (8)-2 5 × (8)-2 0.078

Adding all the product terms to obtain the equivalent decimal number,

(356.25)8 = 192 + 40 + 6 + 0.25 + 0.078 = (238.328)10

Example 2

Convert (527.322)8 to its decimal equivalent.

Solution

We can convert the given octal number to its equivalent decimal number as follows −

Octal Digits Positional Weights Multiply Product
5 (8)2 5 × (8)2 320
2 (8)1 2 × (8)1 16
7 (8)0 7 × (8)0 7
. . . .
3 (8)-1 3 × (8)-1 0.375
2 (8)-2 2 × (8)-2 0.0313
2 (8)-3 2 × (8)-3 0.004

Add all the product terms to obtain the result,

(527.322)8 = 320 + 16 + 7 + 0.375 + 0.0313 + 0.004 = (343.4103)10

Decimal to Octal Conversion

We can convert a mixed decimal number (having integer and fractional parts) to its equivalent octal number. For this, we convert the integer and fractional parts separately.

To convert the integer part of the given decimal number to octal, we divide the given decimal number successively by 8 till the quotient is 0. The octal equivalent is obtained by reading the remainders from bottom to top, where the last remainder will be the most significant digit.

To convert the fractional part of the given decimal number to octal, we multiply the given decimal fraction successively by 8 till the product is 0 or the desired accuracy is obtained. The fractional part of the equivalent octal number is obtained by reading the carries from top to bottom.

Let’s understand the decimal to octal conversion with the help of examples.

Example

Convert (589.278)10 to octal.

Solution

The given decimal number is a mixed number with 589 as integer part and 0.278 as fractional part. Thus, we first convert the integer part to octal and then we convert the fractional part to octal.

Converting Integer Part (589)10 to Octal −

Decimal Remainders
8 589
8 73 5
8 9 1
8 1 1
0 1

Reading the remainders from bottom to top, the equivalent octal of (589)10 is (1115)8.

Converting the Fractional Part (0.278)10 to Octal −

Decimal Product Carry
0.278 × 8 2.224 2
0.224 × 8 1.792 1
0.792 × 8 6.336 6
0.336 × 8 2.688 2

Reading the carries from top to bottom to obtain the fractional part of the equivalent octal number, the result is (0.2162)8.

Thus, the equivalent octal number of (589.278)10 is (1115.2162)8.

Hexadecimal to Binary Conversion

We can convert a hexadecimal number into its equivalent binary by using the mapping method. In this method, we replace each digit of the given hexadecimal number by its equivalent 4-bit binary group.

The following table shows the equivalent 4-bit binary group of each hexadecimal digit −

Hexadecimal Binary
(2)3 = 8 (2)2 = 4 (2)1 = 2 (2)0 = 1
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
A (10) 1 0 1 0
B (11) 1 0 1 1
C (12) 1 1 0 0
D (13) 1 1 0 1
E (14) 1 1 1 0
F (15) 1 1 1 1

Let us understand the conversion of a hexadecimal number to binary number with the help of examples.

Example 1

Convert (3A94.C5D)16 to binary equivalent.

Solution

The given hexadecimal number can be converted into equivalent binary number as follows −

Hexadecimal Number 3 A 9 4 . C 5 D
3 10 9 4 . 12 5 13
4-bit Binary Equivalent 0011 1010 1001 0100 . 1100 0101 1101

Thus, the binary equivalent of the given hexadecimal number is (0011101010010100.110001011101)2.

Example 2

Convert (ABD.2E)16 to binary equivalent.

Solution

The conversion of given hexadecimal number to its binary is done as follows −

Hexadecimal Number A B D . 2 E
10 11 13 . 2 14
4-bit Binary Equivalent 1010 1011 1101 . 0010 1110

Hence, the equivalent binary of (ABD.2E)16 is (101010111101.00101110)2.

Binary to Hexadecimal Conversion

To convert a given binary number to its equivalent hexadecimal number, we create groups of 4 bits each on both sides of the binary point. Then, we replace each group of 4-bit binary by the equivalent hexadecimal digit.

Let us understand the conversion of a binary number to its equivalent hexadecimal with the help of examples.

Example 1

Convert (1110111001101.111011)2 to hexadecimal.

Solution

The conversion of the given binary number to hexadecimal equivalent is done as follows −

4-bit Group 1 1101 1100 1101 . 1110 11
0001 1101 1100 1101 . 1110 1100
Hexadecimal Equivalent 1 D C D . E C

Thus, the hexadecimal equivalent of the given binary number is (1DCD.EC)16.

Example 2

Convert (110111110111.1100)2 to hexadecimal.

Solution

We can convert the given binary number into hexadecimal equivalent as follows −

4-bit Group 1101 1111 0111 . 1100
Hexadecimal Equivalent D F 7 . C

Thus, the hexadecimal equivalent of (110111110111.1100)2 is (DF7.C)16.

Hexadecimal to Decimal Conversion

To convert a hexadecimal number to its equivalent decimal number, we multiply each digit in the hexadecimal number by its positional weight and then add all the product terms to obtain the final result.

The step-by-step procedure to convert a hexadecimal number to its equivalent decimal number is explained below −

Step 1 − Write the positional weights for each hexadecimal digit.

Step 2 − Multiply each hexadecimal digit with its positional weight.

Step 3 − Add the product terms to obtain the equivalent decimal number.

Let us see some examples to understand the conversion of hexadecimal to decimal number.

Example 1

Convert (5AB2.8C)16 to decimal equivalent.

Solution

The conversion of the given hexadecimal number to its decimal equivalent is given below −

Hex Digits Decimal Equiv. Positional Weights Multiply Product
5 5 (16)3 5 × (16)3 20480
A 10 (16)2 10 × (16)2 2560
B 11 (16)1 11 × (16)1 176
2 2 (16)0 2 × (16)0 2
. . . . .
8 8 (16)-1 8 × (16)-1 0.5
C 12 (16)-2 12 × (16)-2 0.0468

Add all the product terms to obtain the equivalent decimal,

(5AB2.8C)16 = 20480 + 2560 + 176 + 2 + 0.5 + 0.0468 = (23218.5468)10

Example 2

Convert (1AF.2)16 to decimal.

Solution

The decimal equivalent of the given hexadecimal number can be obtained as follows −

Hex Digits Decimal Equiv. Positional Weights Multiply Product
1 1 (16)2 1 × (16)2 256
A 10 (16)1 10 × (16)1 160
F 15 (16)0 15 × (16)0 15
. . . . .
2 2 (16)-1 2 × (16)-1 0.125

Adding the product terms to obtain the equivalent decimal number,

(1AF.2)16 = 256 + 160 + 15 + 0.125 = (431.125)10

Decimal to Hexadecimal Conversion

If a mixed decimal number is given that has integer and fraction parts. Then, to convert the given decimal number to its equivalent hexadecimal, we convert integer and fraction parts separately.

To convert the integer part, we successively divide the decimal integer by 16 till the quotient is 0. The integer part of the equivalent hexadecimal is obtained by reading the remainders from bottom to top.

To convert the fractional part, we multiply the decimal fractional number by 16 till the product is 0 or till the desired accuracy is obtained. The fractional part of the equivalent hexadecimal is obtained by reading the carries from top to bottom.

Let us see some examples to understand the decimal to hexadecimal conversion.

Example

Convert (524.26)10 to hexadecimal.

Solution

The given decimal number is a mixed number. Hence, we have to convert its integer and fractional parts separately.

Converting Integer Part (524)10 to Hexadecimal −

Decimal Remainders
16 524
16 32 12 (C)
16 2 0
0 2

Reading the remainder from bottom to top to obtained the hexadecimal equivalent, the result is (20C)16.

Converting Fractional Part (0.26)10 to Hexadecimal −

Decimal Product Carry
0.26 × 16 4.16 4
0.16 × 16 2.56 2
0.56 × 16 8.96 8
0.96 × 16 15.36 15 (F)

Reading the carries from top to bottom to obtain the equivalent hexadecimal number, the result is (0.428F)16.

Thus, the hexadecimal equivalent of the decimal number (524.26)10 is (20C.428F)16.

Octal to Hexadecimal Conversion

The conversion of octal to hexadecimal is very simple. We first convert the given octal number to binary and then the binary number to the hexadecimal.

The step-by-step process to convert a given octal number to its equivalent hexadecimal is given below −

Step 1 − Convert each digit of the given octal number to its equivalent binary of 3-bits.

Step 2 − Make groups of 4 bits each of the obtained binary number.

Step 3 − Convert each 4-bit binary group to its equivalent hexadecimal.

Let us see some examples to understand the conversion of octal to hexadecimal.

Example 1

Convert (742.35)8 to hexadecimal.

Solution

The conversion of given octal number to hexadecimal is explained below −

Octal Digits 3-bit Binary 4-bit Binary Hex Digits
7 111 0001 1
4 100 1110 E
2 010 0010 2
. . . .
3 011 0111 7
5 101 0100 4

Thus, the hexadecimal equivalent of the given octal number is (1E2.74)16.

Example 2

Convert (1523.742)8 to hexadecimal.

Solution

The following table demonstrates the conversion of given octal number to hexadecimal −

Octal Digits 3-bit Binary 4-bit Binary Hex Digits
1 001 0000 0
5 101 0011 3
2 010 0101 5
3 011 0011 3
. . . .
7 111 1111 F
4 100 0001 1
2 010 0000 0

Hence, the hexadecimal equivalent of the given octal number is (353.F1)16.

Hexadecimal to Octal Conversion

The hexadecimal to octal conversion can be perform in the same way as the octal to hexadecimal as explained above. To convert a given hexadecimal number to octal number, we first convert the given hexadecimal number to binary and then the binary number to the octal.

The step-by-step procedure to convert a hexadecimal number to its equivalent octal number is explained below −

Step 1 − Convert each hexadecimal digit to its equivalent 4-bit binary.

Step 2 − Make groups of 3-bits each of the obtained binary number.

Step 3 − Convert each 3-bit binary group to its equivalent octal number.

The following examples demonstrate the method of converting a given hexadecimal number to its equivalent octal number.

Example 1

Convert (B3A9.5F)16 to octal.

Solution

The conversion of the given hexadecimal number to its equivalent octal number is explained below −

Hex Digits B 3 A 9 . 5 F
4-bit Binary 1011 0011 1010 1001 . 0101 1111
3-bit Binary 001 011 001 110 101 001 . 010 111 110
Octal Digits 1 3 1 6 5 1 . 2 7 6

Thus, the octal equivalent of the given hexadecimal number is (131651.276)8.

Example 2

Convert (AC.F)16 to octal.

Solution

The conversion of given hexadecimal number to its equivalent octal number is demonstrated below −

Hex Digits A C . F
10 12 . 15
4-bit Binary 1010 1100 . 1111
3-bit Binary 010 101 100 . 111 100
Octal Digits 2 5 4 . 7 4

Hence, the octal equivalent of the given hexadecimal number is (254.74)8.

Conclusion

We can convert a given number from one base to another. Number system conversion is one the important operations in the field of digital electronics, as it allows to represent the same information in different formats. In this chapter, we explained all the possible number system conversions with the help of examples.

Advertisements