#### NUMBER CONVERSIONS

## Decimal-to-Binary Conversion

Now to convert a number in decimal to a number in binary we have to divide the decimal number by 2 repeatedly, until the quotient of zero is obtained. This method of repeated division by 2 is called the ‘double-dabble’ method. The remainders are noted down for each of the division steps. Then the column of the remainder is read in reverse order i.e., from bottom to top order. We try to show the method with an example shown in Example 1.1. Example 1.1. Convert (26)_{10} into a binary number. Solution:

Hence the converted binary number is (11010)_{2}.

# Decimal-to-Octal Conversion

Similarly, to convert a number in decimal to a number in octal we have to divide the decimal number by 8 repeatedly, until the quotient of zero is obtained. This method of repeated division by 8 is called ‘octal-dabble.’ The remainders are noted down for each of the division steps. Then the column of the remainder is read from bottom to top order, just as in the case of the double-dabble method. We try to illustrate the method with an example shown in Example 1.2.

Example 1.2. Convert (426)_{10} into an octal number. Solution:

Hence the converted octal number is (652)_{8} .

# Decimal-to-hexadecimal Conversion

The same steps are repeated to convert a number in decimal to a number in hexadecimal. Only here we have to divide the decimal number by 16 repeatedly, until the quotient of zero is obtained. This method of repeated division by 16 is called ‘hexdabble.’ The remainders are noted down for each of the division steps. Then the column of the remainder is read from bottom to top order as in the two previous cases. We try to discuss the method with an example shown in Example 1.3.

Example 1.3. Convert (348)_{10} into a hexadecimal number.

Solution:

Hence the converted hexadecimal number is (15C)_{16}

# Binary-to-decimal Conversion:

Now we discuss the reverse method, i.e., the method of conversion of binary, octal, or hexadecimal numbers to decimal numbers. Now we have to keep in mind that each of the binary, octal, or hexadecimal number system is a positional number system, i.e., each of the digits in the number systems discussed above has a positional weight as in the case of the decimal system. We illustrate the process with the help of examples.

Example 1.4. Convert (10110)_{2} into a decimal number.

Solution. The binary number given is 1 0 1 1 0 ——– Positional weights 4 3 2 1 0

The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20 = 16 + 0 + 4 + 2 + 0 = (22)_{10}.

Hence we find that here, for the sake of conversion, we have to multiply each bit with its positional weights depending on the base of the number system.

1.2.5 Octal-to-decimal Conversion

Example 1.5. Convert 3462_{8} into a decimal number.

Solution. The octal number given is 3 4 6 2 ————- Positional weights 3 2 1 0

The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 3 × 83 + 4 × 82 + 6 × 81 + 2 × 80 = 1536 + 256 + 48 + 2 = (1842)_{10}.

# Hexadecimal-to-decimal Conversion

Example 1.6. Convert 42AD_{16} into a decimal number.

Solution. The hexadecimal number given is 4 2 A D —————- Positional weights 3 2 1 0

The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 4 × 163 + 2 × 162 + 10 × 161 + 13 × 160 = 16384 + 512 + 160 + 13 = (17069)_{10}.

# Fractional Conversion

So far we have dealt with the conversion of integer numbers only. Now if the number contains the fractional part we have to deal in a different way when converting the number from a different number system (i.e., binary, octal, or hexadecimal) to a decimal number system or vice versa. We illustrate this with examples.

Example 1.7. Convert 1010.011_{2} into a decimal number.

Solution. The binary number given is 1 0 1 0. 0 1 1 ————— Positional weights 3 2 1 0 -1-2-3

The positional weights for each of the digits are written in italics below each digit. 5 Hence the decimal equivalent number is given as: 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 + 0 × 2–1 + 1 × 2–2 + 1 × 2–3 = 8 + 0 + 2 + 0 + 0 + 0.25 + 0.125 = (10.375)_{10}.

Example 1.8. Convert 362.35_{8} into a decimal number.

Solution. The octal number given is 3 6 2. 3 5 ————- Positional weights 2 1 0 -1-2

The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 3 × 82 + 6 × 81 + 2 × 80 + 3 × 8–1 + 5 × 8–2 = 192 + 48 + 2 + 0.375 + 0.078125 = (242.453125)_{10}.

Example 1.9. Convert 42A.12_{16} into a decimal number.

Solution. The hexadecimal number given is 4 2 A. 1 2 ————- Positional weights 2 1 0 -1-2

The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 4 × 162 + 2 × 161 + 10 × 160 + 1 × 16–1 + 1 × 16–2 = 1024 + 32 + 10 + 0.0625 + 0.00390625 = (1066.06640625)_{10}.

i.e., (0.625)_{10} = (0.101)_{2} Therefore, (25.625)_{10} = (11001.101)_{2}

# Conversion from a Binary to Octal Number and Vice Versa:

We know that the maximum digit in an octal number system is 7, which can be represented as 1112 in a binary system. Hence, starting from the LSB, we group three digits at a time and replace them by the decimal equivalent of those groups and we get the final octal number.

Example 1.11. Convert 101101010_{2} into an equivalent octal number.

Solution. The binary number given is 101101010

Starting with LSB and grouping 3 bits 101 101 010 ——– Octal equivalent 5 5 2

Hence the octal equivalent number is (552)_{8} .

Example 1.13. Convert 1101.0111_{2} into an equivalent octal number.

Solution. The binary number given is 1101.0111

Grouping 3 bits 001 101. 011 100 ————— Octal equivalent: 1 5 3 4

Hence the octal number is (15.34)_{8} .

Example 1.14. Convert 235_{8} into an equivalent binary number.

Solution. The octal number given is 2 3 5

3-bit binary equivalent 010 011 101

Hence the binary number is (010011101)_{2}

# Conversion from a Binary to Hexadecimal Number and Vice Versa:

We know that the maximum digit in a hexadecimal system is 15, which can be represented by 11112 in a binary system. Hence, starting from the LSB, we group four digits at a time and replace them with the hexadecimal equivalent of those groups and we get the final hexadecimal number.

Example 1.16. Convert 11010110_{2} into an equivalent hexadecimal number.

Solution. The binary number given is 11010110

Starting with LSB and grouping 4 bits 1101 0110

Hexadecimal equivalent D 6

Hence the hexadecimal equivalent number is (D6)_{16}.

# Conversion from an Octal to Hexadecimal Number and Vice Versa:

Conversion from octal to hexadecimal and vice versa is sometimes required. To convert an octal number into a hexadecimal number the following steps are to be followed:

(i) First convert the octal number to its binary equivalent (as already discussed above).

(ii) Then form groups of 4 bits, starting from the LSB.

(iii) Then write the equivalent hexadecimal number for each group of 4 bits.

Similarly, for converting a hexadecimal number into an octal number the following steps are to be followed:

(i) First convert the hexadecimal number to its binary equivalent.

(ii) Then form groups of 3 bits, starting from the LSB.

(iii) Then write the equivalent octal number for each group of 3 bits.

Example 1.21. Convert the following hexadecimal numbers into equivalent octal numbers. (a) A72E

Solution: (a) Given hexadecimal number is A 7 2 E

Binary equivalent is 1010 0111 0010 1110 = 1010011100101110

Forming groups of 3 bits from the LSB 001 010 011 100 101 110

Octal equivalent 1 2 3 4 5 6

Hence the octal equivalent of (A72E)_{16} is (123456)_{8} .