Keep Reading

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

DecimalHexadecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

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.