Now that we are aware of how binary number system works, we need to have some knowledge about what hexadecimal system (or hex) is. Like decimal system has a total of 10 digits (0 to 9) and binary has just 2 digits (0 & 1) to represent any data, the hexadecimal system, as the name suggests, has 16 digits to represent any data. The set of digits is as follows:

Hexadecimal | Decimal | Binary |
---|---|---|

0 | 0 | 0000 |

1 | 1 | 0001 |

2 | 2 | 0010 |

3 | 3 | 0011 |

4 | 4 | 0100 |

5 | 5 | 0101 |

6 | 6 | 0110 |

7 | 7 | 0111 |

8 | 8 | 1000 |

9 | 9 | 1001 |

A | 10 | 1010 |

B | 11 | 1011 |

C | 12 | 1100 |

D | 13 | 1101 |

E | 14 | 1110 |

F | 15 | 1111 |

We see that each hexadecimal number consists of 4 bits. Thus, every byte consists of 2 hexadecimal numbers. From the previous article, we know that we wrote 23 in decimal as 00010111 in binary. If we split it into 4 bits each, 0001 & 0111, the same can be written as 17 in hexadecimal. Thus (23)_{10} = (00010111)_{2} = (17)_{16}

Since there are 10 digits in a decimal system, the value of each digit increases by a factor of 10 as we go from right to left in a number. Similarly, the value of each digit increases by a factor of 2 in binary number system as we go from right to left in a number. Extending this logic to the hexadecimal system, the value of each digit will increase by a factor of 16 as we go from right to left in a number. The rightmost digit (known as the least significant digit) of a number always has a Place value of 1 (16^{0}). Similarly the leftmost digit is known as the most significant bit. As we move left, the value of digits is 16 (16^{1}), 256 (16^{2}), and so on in a hexadecimal number system. Thus we see, the Place value of a number increases by a factor of 16 for every digit from right to left. The Face Value of a hexadecimal digit will always be a digit between 0 & F. Let us calculate what the value of the hexadecimal number 17 is in decimal.

Thus, 17 in hexadecimal is equivalent to 23 in decimal. This can be represented as (17)_{16} = (23)_{10}.

Now that we have seen how to convert hexadecimal numbers to decimal numbers, let us see how to convert decimal numbers to hexadecimal. Let us convert 723 in decimal to hexadecimal.

- Dividing 723 by 16, we get quotient as 45, and remainder as 3.
- Dividing 45 by 16, we get quotient as 2, and remainder as 13 (or D as per table above).
- Dividing 2 by 16, we get quotient as 0, and remainder as 2.

Now, if we read the remainders from the bottom to up and write them, we get 2D3, which is equal to the decimal number 723 as we had already calculated earlier. If we convert the hex 2D3 into binary, we get 1011010011, which is again the binary equivalent of 723 as we had calculated earlier.

*For Wikipedia entry on Hexadecimal, click here.*

*For more posts on Computer basics, click here.*

*For more posts in The Cyber Cops project, click here.*