Categories
Coding

HEX Code

Hex is abbreviated from Hexadecimal. It’s widely used by programmers and computer system engineers. To laypeople, Hex code is considered as an untouchable issue that is as much complicated as Quantum Mechanics.

In fact, Hex code already has a very popular and practical application in our life for many years.

IT’S COLOR PICKER.

You definitely used a similar function by your phone, computer or other electronic device. The color you picked is represented by 3 individual 2-digit Hex codes for the setting value of RGB ( abbreviated from Red, Green and Blue).

Hex is simply a new way to count!

Don’t be scared! It’s simply a new way to count.

If you can count 1 to 10, you definitely can count 1 to 16. The concept of Hex code is to collect and group things by 16. We gotta use A, B, C, D, E and F instead of 10, 11, 12, 13, 14 and 15, because a digit can only be represented by a character.

Try to count 1 to 16 by HEX way, it would like: 
1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F and 10(a carry here)

Notice that there's a carry when we count to 16. 
So the number becomes 2 digits to 10.

11 is NOT Eleven

Let's count 1 to 17 by Hex way this time, it would like:
1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F and 10(a carry here), 11

There’s still one thing that I haven’t told you. ‘0x’ is a mark MUST be put in front of a number to represent Hex code. As the example, you have ONE group (0x1, 0x2, 0x3, ….0xD, 0xE, 0xF and 0x10) with one left (0x11), so we can say you totally count 0x11. That’s 16 + 1 = 17.

Dose it make sense to you now ?

Let’s take a challenge to count more, like 44.

It would like:
1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10 
(First group is done),  

11, 12, 13, 14, 15, 16 ,17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20
(Now we have 2 groups, it's 16+16=32) 

21, 22, 23, 24, 25, 26, 27, 28, 29, 2A, 2B, 2C
(We finally count to 44, it's 16+16+12 = 44). 

As above, we know 44 is 0x2C in Hex.

If you are interested in this topic, please take a look at Wikipedia. There’s much detailed information there! https://en.wikipedia.org/wiki/Hexadecimal

Try more counting, and enjoy the new way to count!