Hexadecimal Representation

Hexadecimal (base-16) is a more concise way to represent binary data. Each hexadecimal digit represents exactly 4 binary digits (bits), making it easier to read and write binary values. This perfect 4-bit mapping is why hexadecimal is so useful:

Why 4 bits?

  • 4 bits can represent 16 different values (2⁴ = 16)
  • Hexadecimal uses 16 symbols: 0-9 and A-F
  • This creates a perfect one-to-one mapping
  • Each hex digit exactly represents one 4-bit chunk

Why not decimal?

  • Decimal digits don't map cleanly to binary
  • Example: 0xAB (hex) = 10101011 (binary) = 171 (decimal)
  • The decimal "171" obscures the underlying bit pattern
  • Hex "AB" clearly shows two 4-bit chunks: A (1010) and B (1011)

This is particularly useful when working with computer systems, as 8 bits (1 byte) can be represented with just 2 hexadecimal digits. The clean 4-bit grouping makes it easy to convert between binary and hex in your head, while decimal requires more complex calculations.

Binary:
1
0
1
0
1
0
1
1
(8 characters)
Decimal:
1
7
1
(3 characters)
Hex:
A
B
(2 characters)

Hex to Binary Mapping

0
=
0
0
0
0
1
=
0
0
0
1
2
=
0
0
1
0
3
=
0
0
1
1
4
=
0
1
0
0
5
=
0
1
0
1
6
=
0
1
1
0
7
=
0
1
1
1
8
=
1
0
0
0
9
=
1
0
0
1
A
=
1
0
1
0
B
=
1
0
1
1
C
=
1
1
0
0
D
=
1
1
0
1
E
=
1
1
1
0
F
=
1
1
1
1

Why Use Hexadecimal?

  • More compact than binary (4 bits per character vs 1)
  • Easier to read and write than long binary strings
  • Natural mapping to bytes (2 hex digits = 1 byte)
  • Commonly used in programming for memory addresses and color values
  • Less error-prone when transcribing values