My trick for reading hex code!

Опубликовано: 11 Июль 2026
на канале: EmbSys
5,866
94

What is Hex Code? What is it used for?
And why the heck it is so difficult to read?
It isn't at all: Use my secret trick and Hex Code will only cost you a weary smile!

Timestamps:
0:00 Read HexCode
3:37 The trick
9:21 Exercises

Credits:
Jo @ jn3008   / jn3008   (Inspired Outro Graphic)
https://www.washhouse-basement-stompe... (Outro Music)

_____________________

Script (excerpt):

I always ask my students the question: 0x1D4C - Can you understand what is meant by this?
Then nothing happens for a while, but then some clever student takes pity on me and pulls out her calculator (I hope you know the "programmer" mode of the Windows calculator, which is excellent) and then she says: 7500! And she's right there.
First of all, why do we use hexadecimal numbers at all?
And the simple answer: Hex is always used when a specific bit pattern is to be displayed.
Example: all bits zero, but bit number 3 is one
If I calculate the temperature at the North Pole or want to determine the speed of a skydiver in free fall, I will of course specify my parameters in decimal. I will never ask 0x0B pretzels from the baker.
Then why Hex?
The data sheet says, for example:
"To select the operating mode, a bit combination according to the table below should be entered in bits 4 to 6 of an 8-bit register."
Then hexadecimal makes sense.
Use hex when it makes sense. But ONLY then, please!

Now let's go:
First of all, remember that a byte always consists of TWO hexadecimal digits. Two so-called nibbles. A nibble is represented as one of 16 possible digits:
Use the digits from 0 to 9 and six more from A to F.
0, 1, 2, 3 stands for the decimal 0, 1, 2, 3, after 9 comes A, so 10. B is 11, and F finally 15.
The 16 no longer fits in the first nibble, so we need the next digit, i.e. 0x10.
To indicate that it is a hexadecimal representation, an H is often added to the number, sometimes a small 16 or the word "hex"
Examples: 2716, 27hex, 27h, 27H, 27H,
In C and related programming languages, however, a "0x" is placed in front of the first digit:
0x27

Let's look at the 16 possible binary combinations for the nibble:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

What you clearly do NOT have to remember:
0000 stands for zero.

I don't have to remember 0001 either. That is the one.
This also applies to the combinations that only consist of a single one:
0001 0010 0100 1000
The computer scientist knows these very well, they are the famous powers of two.
Doubling.
0001 is the 1,
0010 is double, i.e. the 2.
0100 doubled again, i.e. the 4th
And 1000 the third doubling, the eight.
We don't remember, we know anyway.

Then we start at the top: the last digit, the largest, is the F. Because that is the largest, all bits are 1, i.e. 1111.
And now comes my first trick: The seven and the three.
We know the 8.
This is the first combination that no longer fits in three bits, we need a 4th bit for the one. The other three are still 0.
So 1000.
The next lower digit, 7, still fit in three bits.
Therefore: 0111 is the 7th
The same for three:
the 4 (0100) needs three bits, the three fits in two bits, i.e. 0011

Second trick: adding one is very easy in binary as long as there is no carry.
So whenever the smallest bit is zero, I can easily add one in my head,
by setting the smallest bit to one.
0000 becomes 0001,
2 (0010) becomes 3 (0011),
4 (0100) becomes 5 (0101),
8 (1000) becomes 9 (1001).
For free.

We already have a few. Actually, only the bad area between A and E.
NOW I'm pulling my trump card out of my sleeve:
I had already announced: You have to learn two combinations by heart.
Learn the A and the C!
I can remember A well, the bit pattern is 1010, always alternating.
A means decimal ten, you can just as easily memorize ten-ten.
The bit pattern for C is 1100.
Unfortunately, I don't know any donkey bridge there.

With A and C we also know B and D. Just add one more.
B is 1011, D is 1101

Just count it, we'll be through in a moment. Now only 6 and E.
We have to decipher the two by subtracting them, admittedly, that's a small flaw in my system. F is clear: 1111, and E is just one less: 1110.
We derive the 6 from the 7: 0110 instead of 0111.
Finished!
The next time you come across a hexadecimal number: don't be alarmed. Think of my perfidious trick and laugh quietly to yourself.
You can start right away. As a reminder, A is 1010 and C is 1100.