While working with binary numbers, we can note that representation of larger number may become problematic. For example, if one has to do mathematical operations with 32-bit number or any other larger number, he may face problem in writing them and doing calculation. Some of the bits may be missed or written incorrectly. To avoid this problem, Hexadecimal number system is used. In this system, there are 16 digits (symbols). Each digit is the representation of 4 bit binary number so we can say that 4 bit binary number requires single hexadecimal digit, 8 bit binary number requires 2 hexadecimal digits, similarly 12 bit binary number requires 3 hexadecimal digits and so on. As this system has 16 different digits, its base is 16. 16 digits are comprised of numeric characters 0 through 9 and then block alphabetic characters A, B, C, D, E and F which are equivalent to decimal 10 through 15 respectively. Table 1.2 summarizes the relationship among binary, decimal and hexadecimal numbers.
Hexadecimal | Decimal Number | Binary Numbers | |||
MSB | LSB | ||||
0 | 0 | 0 | 0 | 0 | 0 |
1 | 1 | 0 | 0 | 0 | 1 |
2 | 2 | 0 | 0 | 1 | 0 |
3 | 3 | 0 | 0 | 1 | 1 |
4 | 4 | 0 | 1 | 0 | 0 |
5 | 5 | 0 | 1 | 0 | 1 |
6 | 6 | 0 | 1 | 1 | 0 |
7 | 7 | 0 | 1 | 1 | 1 |
8 | 8 | 1 | 0 | 0 | 0 |
9 | 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 |
Table 1.2
In hexadecimal system, counting after FH (where subscript “H” represent hexadecimal number system) continues in the same way as explained before. This means after FH there comes 10H, 11H, 12H, 13H, 14H, 15H, 16H, 17H, 18H, 19H, 1AH, 1BH, 1CH, 1DH, 1EH, 1FH, 20H and so on. So in this way, we can count up to FFH using two hexadecimal digits which equal 25510 and 111111112. Note that when there is a 9 in digit place, it becomes A when increamented and overflow condition occurs when F comes at certain digit place. Digit positions in a hexadecimal number have the weight as follows.
166 | 165 | 164 | 163 | 162 | 161 | 160 | 16-1 | 16-2 | 16-3 | 16-4 | 16-5 | 16-6 | 16-7 |
. Hexadecimal Point | |||||||||||||
Binary-to-Hexadecimal Conversion:
From table 1.2, it is clear that the largest digit i.e., FH needs 4 bits (also called nibble) to be represented. Therefore, we break the binary numbers into groups of a nibble starting from right-most bit (LSB) and proceeding towards left-hand bit (MSB). If there are some bits left on the left hand side of a binary number which cannot make a nibble, we append “0” to the left of a number to get nibble completed. This is illustrated by example 1.5.![]() |
| Example 1.5 (Click image to enlarge) |
Hexadecimal-to-Binary Conversion:
| Example 1.6 (Click image to enlarge) |
Decimal-to-Hexadecimal Conversion:
Recall from the repeated division method for decimal-to-binary conversion (can be seen here) that the division of decimal number by the base of the system in which conversion needs to be made will give the desired number. Here the base is “16”. Following example (1.7) explains the procedure.| Example 1.7 (Click image to enlarge) |
Like before, division stopped when the quotient is less than the base of number system, i.e., “16” in this case.
Hexadecimal-to-Decimal Conversion:
Recall from previous discussion that weight “W” of “nth” digit (bit in case of binary number system) in a given number represented in number system with base “X” can be calculated as:
W = Xn
Where n = 0 for LSD and increases as we move from right most digit to the left most.
| Example 1.8 (Click image to enlarge) |
| Example 1.9 (Click image to enlarge) |
References:
1. Ronald J. Tocci and Neal S. Widmer, Digital Systems Principles and Applications, 7th Edition, Prentice-Hall, New Jersey.
2. Thomas L. Floyd, Digital Fundamentals, 7th Edition, Prentice-Hall, New Jersey.
