Conversion of Number Systems (Various possible conversions explained below)
Table of Contents
Any base R to Decimal Number system conversion
For conversion of any base R number to Decimal number system each coefficient is multiplied with the corresponding power of R and added to obtain the decimal number.
Binary to Decimal conversion
(1101.01)2 = 1 × 23 + 1×22 + 0 × 21 + 1 × 20 + 0 × 2(-1) + 1 × 2(-2) = (13.25)10
Octal to Decimal conversion
(431.2)8 = 4 × 82 + 3 × 81 + 1 × 80 + 2 × 8(-1) = (281.25)10
Hexadecimal to Decimal conversion
(6E9.D8)16 = 6 × 162 + 14 × 161 + 9 × 160 + 13 × 16(-1) + 8 × 16(-2) = (1769.84375)10
Base 5 to Decimal conversion
(421.3)5 = 4 × 52 + 2 × 51 + 1 × 50 + 3 × 5(-1) = (111.6)10
Likewise any number of base R can be converted to Decimal number system
Decimal to any base R number system conversion
For conversion of Decimal number system to any base R, the decimal number (Integer part) is divided by R and the remainders obtained at each stage are used to represent the base R representation of the decimal number system. For fractional part the digits are multiplied by R and resulting digits integer part is used to define the number.
Decimal to Binary conversion
(31.6875)10 = (?)2
For Integer part, the number is divided by 2 and the remainders are read in the direction of arrow from down to top corresponding to MSB and LSB as shown below
For fractional part, the digits are multiplied by two and integer part defines the number as shown below, the numbers are now read from top to bottom as shown by arrow, the multiplication is done ideally till the decimal part or fractional part becomes zero or the repetition starts.
Decimal to Octal
(152.512)10 = (?)8
For Integer part, the number is divided by 8 and the remainders are read in the direction of arrow from down to top corresponding to MSB and LSB as shown, this gives (152)10 = (230)8
For fractional part, the digits are multiplied by eight and integer part defines the number as shown below, the numbers are now read from top to bottom as shown by arrow, the multiplication is done ideally till the decimal part or fractional part becomes zero or the repetition starts.
Decimal to Hexadecimal
(2607.565)10 = (?)16
For Integer part, the number is divided by 16 and the remainders are read in the direction of arrow from down to top corresponding to MSB and LSB as shown, this gives (2607)10 = (A2F)16
For fractional part, the digits are multiplied by sixteen and integer part defines the number as shown below, the numbers are now read from top to bottom as shown by arrow, the multiplication is done ideally till the decimal part or fractional part becomes zero or the repetition starts.
Likewise any decimal number can be converted into any base R by following the procedure as illustrated
Binary to Octal conversion
Any octal digit corresponds to three binary digits. So to represent any binary number into octal number system the binary digits are grouped as three bits together from LSB to MSB for integer part of number, if groupings of three are not possible then zeroes are padded before the MSB and for fractional part the groupings are done towards right of decimal point and zeroes are padded towards right at the end of the number to make groupings of three.
Since each binary number is a positional number and each bit corresponding to weights of powers of two, groupings of three gives equivalent octal number. For example (110)2 = 1 × 22 + 1 × 21 + 0 × 20 = (6)8. This can also be understood as 421 coding where each 421 represents the weights of the three positions and 1 at any position is equal to that weight being accounted. For example 101 means weight 4 and weight 1 are accounted, so equivalent is 4+1 =5 in octal representation. Below table gives the binary and its equivalent octal representation
Octal Number | Equivalent Binary number (421 coding) |
0 | 000 (0x4+0x2+0x1) |
1 | 001 (0x4+0x2+1×1) |
2 | 010 (0x4+1×2+0x1) |
3 | 011 (0x4+1×2+1×1) |
4 | 100 (1×4+0x2+0x1) |
5 | 101 (1×4+0x2+1×1) |
6 | 110 (1×4+1×2+0x1) |
7 | 111 (1×4+1×2+1×1) |
Table 1 : Octal Binary equivalent
Say a binary number is given as (1101010101111000101.1110000011), to find its equivalent octal representation as per the method detailed above
Octal to Binary conversion
For converting any octal number to binary, the binary representation as detailed above in Table 1 is to be written for each octal digit.
(672.421)8 = (110 111 010. 100 010 001)2
Binary to Hexadecimal conversion
Any hexadecimal digit corresponds to four binary digits. So to represent any binary number into hexadecimal number system the binary digits are grouped as four bits together from LSB to MSB for integer part of number, if groupings of four are not possible then zeroes are padded before the MSB and for fractional part the groupings are done towards right of decimal point and zeroes are padded towards right at the end of the number to make groupings of four.
Since each binary number is a positional number and each bit corresponding to weights of powers of two, groupings of four gives equivalent hexadecimal number. For example (1110)2 = 1 × 23 + 1 × 22 + 1 × 21 + 0 × 20 = (14 = E)16. This can also be understood as 8421 coding where each 8421 represents the weights of the four positions and 1 at any position is equal to that weight being accounted. For example 0101 means weight 4 and weight 1 are accounted, so equivalent is 4+1 =5 in hexadecimal representation. Below table gives the binary and its equivalent hexadecimal representation
Hexadecimal Number | Equivalent Binary number (8421 coding) |
0 | 0000 (0X8+0x4+0x2+0x1) |
1 | 0001 (0X8+0x4+0x2+1×1) |
2 | 0010 (0X8+0x4+1×2+0x1) |
3 | 0011 (0X8+0x4+1×2+1×1) |
4 | 0100 (0X8+1×4+0x2+0x1) |
5 | 0101 (0X8+1×4+0x2+1×1) |
6 | 0110 (0X8+1×4+1×2+0x1) |
7 | 0111 (0X8+1×4+1×2+1×1) |
8 | 1000 (1X8+0x4+0x2+0x1) |
9 | 1001 (1X8+0x4+0x2+1×1) |
A | 1010 (1X8+0x4+1×2+0x1) |
B | 1011 (1X8+0x4+1×2+1×1) |
C | 1100 (1X8+1×4+0x2+0x1) |
D | 1101 (1X8+1×4+0x2+1×1) |
E | 1110 (1X8+1×4+1×2+0x1) |
F | 1111 (1X8+1×4+1×2+1×1) |
Table 2: Hexadecimal Binary equivalent
Say a binary number is given as (1101010101111000101.1110000011), to find its equivalent hexadecimal representation as per the method detailed above
Hexadecimal to Binary conversion
For converting any hexadecimal number to binary, the binary representation as detailed above in Table 2 is to be written for each hexadecimal digit.
(2C6B.E2)16 = (0010 1100 0110 1011. 1110 0010)2