The original article has been published on my previous blog. I re-shared it here as a useful reference!
What is Hexadecimal? It is a base 16 number starting with 0 – 9 (representing the first 10 digits) and A – F
(representing the 6 last digit, where A represent the decimal 10 and F represent the decimal 15).
What about binary? It is a base 2 number that contain 1s and 0s. To understand what I
am going to tell you, you need to understand how our decimal number system work, and that a regular decimal number is
the sum of the digits multiplied with a power of its base 10 (because decimal numbers are base 10).
Decimal Numbers
For example, the decimal number 256 in base 10 is equal to each digit multiplied with its corresponding power and its base 10:
(start to the right for the power of 0 and go to the left for the next power)
- 6 x (100 = 1) So, 6 x 1 = 6
- 5 x (101 = 10) So, 5 x 10 = 50
- 2 x (102 = 100) So, 2 x 100 = 200
Hexadecimal Numbers
Now that you know that, you can implement the same process for hexadecimal numbers and its corresponding power and base 16.
Let’s take the example of the Hex Digit: AE26
- 6 x (160 = 1) So, 6 x 1 = 6
- 2 x (161 = 16) So, 2 x 16 = 32
- E x (162 = 16 x 16 = 256) So, E = 14 x 256 = 3584
- A x (163 = 16 x 16 x 16 = 4096) So, A = 10 x 4096 = 40960
Binary Numbers
It is the same process with the binary numbers and its corresponding power and base 2. For example, the binary number 1011 it will be:
- 1 x (20 = 1) So, 1 x 1 = 1
- 1 x (21 = 2) So, 1 x 2 = 2
- 0 x (22 = 4) So, 0 x 4 = 0
- 1 x (23 = 8) So, 1 x 8 = 8
Here are some key ideas to memorize;
-
- Always start from the right to the left when doing the math.
- Decimal Numbers are based 10
- Hexadecimal Numbers are base 16
- Binary Numbers are base 2