## What is Hexadecimal?

Compared to decimal (0-9), hexadecimal is a 16-based numbering system using 16 digits (0123456789ABCDEF). Since in classic math, there are only 10 numbers, the letters from A to F are used to represent the rest of numbers in hexadecimal.

Decimal/Hexadecimal/Binary value reference table

Decimal | Hexadecimal | 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 |

10 | A | 1010 |

11 | B | 1011 |

12 | C | 1100 |

13 | D | 1101 |

14 | E | 1110 |

15 | F | 1111 |

## Why Do We Use Hexadecimal?

In programming, we often use decimal system since programming language need to be human-readable. However, because the representation of data in computer eventually exists in the form of binary, sometimes using binary can solve the problem more intuitively. But the binary format is too long, for example, to express 100 in binary would be: 0000 0000 0000 0000 0110 0100. it is hard to directly think and operate with such long number. Therefore, a lot of programming language like C and C++ are not provide a way to write binary numbers directly in the code. Using hexadecimal can solve this problem since the larger base makes the expression length of the number much shorter.

But why use 16 as base in hexadecimal, why not use other number like 9 or 20? The reason is 16 the forth power of 2. This makes conversion between a hexadecimal number and a binary number very straightforward. Hexadecimal shorten binary numbers, but maintains the expression characteristics of binary numbers.