Number Conversion

The binary number system is the most important one in digital system as it is very easy to implement in circuitry.

The decimal system is important because it is universally used to represent quantities outside a digital system.

This session tells you how to perform conversion from one system to another

Like decimal to binary, decimal to octal, decimal to hexadecimal and vice versa.

So, let us discuss them one by one.
Decimal to Binary Conversion

A popular way to convert decimal number is the double dabble method.

In this method the decimal number is divided by 2, writing down the remainder after each division.

The remainders are taken in reverse order to form the binary number.

For example, convert 25_{10} to binary number


Hence the result will be as shown below
25_{10} = 11001_{2}
Decimal to Binary Conversion (Fractions)

In this case, the decimal number is multiplied by 2 and the carry is recorded in the integer position.

The carries are taken in downward direction (from top to bottom) to obtain the required binary fraction.

The process can be stopped either after getting the result as zero or after getting six binary digits.

For example convert 0.85_{10} to binary number

Hence the result of 0.85_{10 }is
0.85_{10 }= 0.11.110_{2} 
Binary to Decimal Conversion

In this case the binary number is multiplied by its positional values, where each binary digit carries a certain weight based on its position relative to the LSB.

The bit position of binary digit is given below

In that each value is multiplied with the base 2 and its power

For example
2^{1 }= 2 x 1 = 2 and so on

The following figure explains the bit position

Let us consider an example of converting 10101_{2} to decimal
Note: The alternate method for converting binary to decimal is done by the following step 
 Write the binary number
 Write the weights 1, 2, 4, 8.....(2^{0}, 2^{1}, 2^{2}, 2^{3}......) under the corresponding binary numbers
 Cross out the weight of binary numbers as '0' (zero).
 Add the remaining weights to get the equivalent decimal number.
 Example : convert 1011 to its equivalent decimal number as
Step 2: 8 4 2 1
Step 3: 8 4 2 1
Step 4: 8 + 0 + 2 + 1
Binary to Decimal Conversion (Fractions)
 To find the decimal equivalent of binary fraction, take the sum of the products of each digit value and its positional value
 For example
 1101.000101_{2} to decimal
Decimal to Octal Conversion
 Decimal to octal conversion can be accomplished using the double dabble method presented in the last section.
 The integer part is converted with repeated divisions by the base 8 in the above example.
 This is easily converted by the following procedure
 For example convert 444_{10} to octal
 Hence the result for
444_{10} = 673_{8} 
Decimal to Octal Conversion (fraction)
 In this conversion, the decimal number is multiplied by 8 and the carry is recorded in the integer position.
 The carries are written in down direction to obtain the required octal number
 For example, Convert 0.82_{10} to its equivalent octal number
 Hence the result of
0.82_{10 }is 643656_{8 } 
Octal to Decimal Conversion
 The weight of an octal number is eight.
 Therefore to convert an octal number to its equivalent decimal number, multiply each octal digit by its weight and then add the resulting products.
= 1 7 5 = 1 x 8^{2} + 7 x 8^{1} + 5 x 8^{0} = 1 x 64 + 7 x 8 + 5 x 1 = 64 + 56 + 5 = 125_{10} 
Octal to Decimal conversion (fraction)
 An octal number can be easily converted into decimal; the procedure is to successively multiply the decimal fraction by the radix.
 Base and collect all the numbers to the left of the decimal point, reading down.
 For example, convert the fractional number 0.45_{8} to its equivalent decimal number
= 0. 4 5 = 4 x 8^{1} + 5 x 8^{2} = 4 x 1 / 8 + 5 x 1 /64 = 0.5 + 0.578125 = 0.578125_{10} 
 Hence the result of
0.45_{8 = }0.578125_{10} 
Decimal to Hexadecimal conversion
 A hex dabble method, similar to double dabble method.
 Divide the decimal number by 16 and write down the remainder after each division.
 The remainder in reverse order form the octal number
 For example, convert 6538_{10} to its hexadecimal equivalent
Write from bottom to top to obtain the result
 Hence the result of
6538_{10} = 198A_{16 } 
Note: on the above example the value of 10 is termed as A because according the hexadecimal the conversion of 10 is A. 
 In this conversion, the decimal number is multiplied by 16 and records the carry in the integer's position.
 The carries are written in downward direction, to obtain the required hexadecimal number.
 For example, convert a fractional decimal 935_{10} to hexadecimal number
Write the result in downward direction
 Hence the result of
.935_{10} = EF5C28_{16} 
Hexadecimal to Decimal Conversion
 The weight of the hexadecimal number is 16.
 Therefore to convert a hexadecimal number to its equivalent decimal number, multiply each hexadecimal digit by its weight
 Then add the resulting products
 For example, convert A25 to its equivalent decimal number
 Hence the result of
A25_{16} = 2597_{10} 
 To convert the fractional part of the number, repeated multiplications are required.
 For example, convert .B5_{16} to decimal equivalent
= . B 5 = B x 1/ 16^{1} + 5 X 1/16^{2} = 11 x 0.0625 + 5 x 0.00390625 = 0.6875 + 0.0195312 = 0.7070312 
 Hence the result of
.B5_{16 = }0.7070312_{10} 
Binary to Hexadecimal conversion
 This method is made by grouping the numbers into four starting at the binary point.
 The following table gives the conversion of hexadecimal to binary equivalent number
Hexadecimal number 
Equivalent Binary number 

0 
0000 

1 
0001 

2 
0010 

3 
0011 

4 
0100 

5 
0101 

6 
0110 

7 
0111 

8 
1000 

9 
1001 

10 
1010 

11 
A 
1011 
12 
B 
1100 
13 
C 
1101 
14 
D 
1110 
15 
E 
1111 
 For example convert a binary number 10111110101011. 1011101011 to its equivalent hexadecimal number
 The binary number is grouped as follows
Hexadecimal to binary conversion
 Like the octal number system, the hexadecimal number system is used primarily as a shorthand method.
 This method is the reverse method of converting the binary to hexadecimal.
 For example convert BAD_{16} to binary equivalent
= B A D = 11 10 13 = 1011 1010 1100 = 101110101100_{2} 
 Hence the result of
BAD_{16 }= 101110101100_{2} 
Binary to Octal Conversion
 In this method, first the binary number is arranged in group of 3 bits from right to left
 Suppose the binary numbers are not completely in the form of 3 digits, sufficient zeros are added to the left most side of integer number
 And also sufficient zeros are added to the right most side of the fractional number
 The following table gives the binary equivalent values for the given octal number
Octal number 
Equivalent Binary number 
0 
000 
1 
001 
2 
010 
3 
011 
4 
100 
5 
101 
6 
110 
7 
111 
 For example convert the binary number of 10110111. 10111_{2 }to its equivalent octal number
 Hence the result of
10110111. 10111_{2 }= 267.56_{8} 
Octal to Binary Conversion
 The weight of an octal number is 8 and the weight of the binary number is 2
 The weight of the octal is the third power of binary (2^{3}= 8)
 Hence in octal to binary conversion, each octal digit is converted into its equivalent three digit binary form.
 For example convert an octal number 326.54_{8} to its equivalent binary value
= 3 2 6 .5 4 = 011 010 110 . 101 100 = 11010110.101100_{2} 
 Hence the result of
326.54_{8 }= 11010110.101100_{2} 