How to Convert Hexadecimal to Decimal?


Whereas Hexadecimal number is one of the number systems which has value is 16 and it has only 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, F. Where A, B, C, D, E and F are single bit representations of decimal value 10, 11, 12, 13, 14 and 15 respectively. Whereas Decimal system is most familiar number system to the general public. It is base 10 which has only 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

Conversion from Hexadecimal to Decimal number system

There are various indirect or direct methods to convert a hexadecimal number into decimal number. In an indirect method, you need to convert a hexadecimal number into binary or octal number, then you can convert it into decimal number.

Example − Convert hexadecimal number F1 into decimal number.

First convert it into binary or octal number,
= (F1)16
= (1111 0001)2   or  (011 110 001)2
Because  in binary, value of F and 1 are 1111 and 0001 respectively. Then convert it into decimal number multiplying power of its position of base.
= (1x27+1x26+1x25+1x24+0x23+0x22+0x21+1x20)10   or   (3 6 1)8

= (1x27+1x26+1x25+1x24+0x23+0x22+0x21+1x20)10 or (3x82+6x81+1x80)10 = (241)10

However, there is a simple direct method to convert a hexadecimal number to decimal number. Since, there are only 16 digits (from 0 to 7 and A to F) in hexadecimal number system, so we can represent any digit of hexadecimal number system using only 4 bit as following below.

Hexa 0 1 2 3 4 5 6 7

Binary 0000 0001 0010 0011 0100 0101 0110 0111

Hexa 8 9 A=10 B=11 C=12 D=13 E=14 F=15
Binary 1000 1001 1010 1011 1100 1101 1110 1111

Hexadecimal number system provides convenient way of converting large binary numbers into more compact and smaller groups. These are weights of hexadecimal of respective position of hexadecimal (value of base is 16).

Most Significant Bit (MSB) Hexa Point Least Significant Bit (LSB)
162 161 160 16-1 16-2 16-3
256 16 1 1/16 1/256 1/4096

Since number numbers are type of positional number system. That means weight of the positions from right to left are as 160, 161, 162, 163and so on. for the integer part and weight of the positions from left to right are as 16-1, 16-2, 16-3and so on. for the fractional part.

You can directly convert a hexadecimal number into decimal number using reverse method of decimal to hexadecimal number.

Assume any unsigned hexadecimal number is hnh(n-1) ... h1h0.h-1h-2 ... h(m-1)hm. Then the decimal number is equal to the sum of hexadecimal digits (hn) times their power of 16 (16n), i.e.,

= hnh(n-1) ... h1h0.h-1h-2 ... h(m-1)hm

= hnx16n+h(n-1)x16(n-1)+ ... +h1x161+h0x160+h-1x16-1+h-2x16-2+ ... +h(m-1)x16-(m-1)+h-mx16-m

This is simple algorithm where you have to multiply positional value of binary with their digit and get the sum of these steps.

Example-1 − Convert hexadecimal number ABCDEF into decimal number.

Since value of Symbols: A, B, C, D, E, F are 10, 11, 12, 13, 14, 15 respectively. Therefore equivalent decimal number is,

= (ABCDEF)16
= (10x165+11x164+12x163+13x162+14x161+15x160)10

= (10485760+720896+49152+3328+224+15)10 = (11259375)10 which is answer.

Example-2 − Convert hexadecimal number 1F.01B into decimal number.

Since value of Symbols: B and F are 11 and 15 respectively. Therefore equivalent decimal number is,

= (1F.01B)16
= (1x161+15x160 +0x16-1+1x16-2+11x16-3)10
= (31.0065918)10 which is answer.
raja
Published on 06-Dec-2018 16:12:40
Advertisements