Hexadecimal numbers

Introduction to the hexadecimal base-16 system.

Published

October 2, 2025

Modified

March 14, 2026

Hexadecimal Numbers ๐Ÿ”ข๐ŸŸช

As we saw with Unicode, computers need to handle very large numbers to distinguish between the many possible characters and instructions. While computers work effortlessly with large binary numbers, we donโ€™t! Converting 32-bit or 64-bit values from binary to decimal is tedious, which makes large binary numbers difficult for humans to read and write quickly.

Weโ€™re comfortable with large decimal numbers, but the problem is that 10 is not a power of 2. This means it doesnโ€™t align neatly with the binary storage model computers rely on. For example, with just 4 bits we can represent values up to 16, but to store something slightly larger, like 17โ€“20, we already need 5 bits.

The result is that decimal numbers cannot be directly stored in machines built from transistors that only distinguish between โ€œonโ€ (1) and โ€œoffโ€ (0). So whatโ€™s the solution? We turn to hexadecimalโ€”a system that maps perfectly onto binary while staying compact and much easier for humans to read and write.

Notice that 16 is a power of 2: \(2^4 = 16\). This means every 4 bits (a nibble) can store one hexadecimal digit (a โ€œhexitโ€), and with 8 bits we can store two โ€œhexitsโ€.

Hexits ๐Ÿ”น

The hexadecimal system is base 16 ๐Ÿ”ข. This means we count from 0 to 15 before moving to the next place value. In decimal, we only have the digits 0โ€“9 ๐Ÿ”Ÿ. To show the extra numbers (10โ€“15), we use the letters A, B, C, D, E, and F ๐Ÿ” .

Hexadecimal Binary Decimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
A 1010 10
B 1011 11
C 1100 12
D 1101 13
E 1110 14
F 1111 15

Building Hexadecimal Numbers ๐Ÿ—๏ธ

Binary to Hexadecimal 0๏ธโƒฃ1๏ธโƒฃ

Going from binary to hexadecimal and vice versa is quite straight forward.

๐Ÿš€ Steps:

  1. Group the binary number in nibbles (packs of 4 bits) ๐Ÿ‘‰ Example : 0101011011 โ†’ 0001 0101 1011

  2. Convert each nibble into its hexadecimal digit:

  • (0001)2 โ†’ (1)16
  • (0101)2 โ†’ (5)16
  • (1011)2 โ†’ (B)16
  1. Write the hex digits in the same order. โœจ 0001 0101 1011 โ†’ (15B)16

Hexadecimal numbers are often written with the prefix 0x to make their base clear:

0001 0101 1011 = 0x15B

โœ… Final Answer: 0x15B

Apply the same approach to convert a hexadecimal number to binary, each hex character will correspond to a nibble (4 bits).

๐Ÿ”ข Decimal to Hexadecimal

This is a little less straight forward but itโ€™s still achievable.

๐Ÿš€ Steps: ๐Ÿ‘‰ Example: Letโ€™s convert 4,284 in hexadecimal:

  1. List a few powers of 16 and their decimal values:
Power of 16 \(16^4\) \(16^3\) \(16^2\) \(16^1\) \(16^0\)
Decimal 1,048,576 4,096 256 16 1
  1. Find the largest power of 16 that fits into 4,284. ๐Ÿ‘‰ \(16^3 = 4,096\) (fits, since \(16^4\) is too big).

  2. Divide by this power of 16. ๐Ÿ‘‰ \(4284 รท 4096 = 1\) remainder 188. ๐Ÿ”น Next digit: 1

  3. Use the next power of 16 (\(16^2 = 256\)). ๐Ÿ‘‰ \(188 รท 256 = 0\) remainder 188. ๐Ÿ”น Next digit: 0

  4. Move to the next power \(16^1 = 16\). ๐Ÿ‘‰ \(188 รท 16 = 11\) remainder 12. ๐Ÿ‘‰ Decimal 11 = Hex B. ๐Ÿ”น Next digit: B

  5. Finally, \(16^0 = 1\). ๐Ÿ‘‰ \(12 รท 1 = 12\) remainder 0. ๐Ÿ‘‰ Decimal 12 = Hex C. ๐Ÿ”น Next digit: C

  6. Write the hexadecimal digits in the order of largest to lowest powers:

โœ… Final Answer: 0x10BC

Riddle

Avatar Aang went to get his first driving license. The clerk asked Aang for his ID to make sure he was old enough to do the driving test. The clerk read his ID, and told him that he is not old enough for the test. They him that he needs to be at least 18.

Aang answered, โ€œIโ€™m sorry but you are wrong. I am exactly 18, in decimal. My ID in fact shows my age in Hexadecimal.โ€

What age is Aang in Hexadecimal(if he is indeed 18 in decimal?)

Sample alt text. To be replaced!

Avatar Aang.
Back to top