Hexadecimal Number System

Understanding Base 16 - The Compact Binary Representation

What is Hexadecimal?
Definition
Hexadecimal = base 16 number system
Digits: 0–9 and A–F
A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
Each position represents a power of 16.
Computers use it because 1 hex digit = 4 binary bits (very compact).
Example
(2F)₁₆ = (2 × 16¹) + (15 × 16⁰)
= 32 + 15 = 47 in decimal
Relation with Binary
1 hex digit = 4 binary digits
Easy conversion between binary ↔ hex.
0
=
0
0
0
0
1
=
0
0
0
1
2
=
0
0
1
0
3
=
0
0
1
1
8
=
1
0
0
0
9
=
1
0
0
1
A
=
1
0
1
0
F
=
1
1
1
1
Example 1: Binary to Hexadecimal
(10101101)₂ → group into 4 bits: (1010)(1101) → A D → AD₁₆
Example 2: Hexadecimal to Binary
(3B)₁₆ → 3 = 0011, B = 1011 → 00111011₂
Conversions
Decimal → Hexadecimal
Method: Division by 16
1
754 ÷ 16 = 47 remainder 2
2
47 ÷ 16 = 2 remainder 15 (F)
3
2 ÷ 16 = 0 remainder 2
Reading remainders bottom → top: 2F2₁₆
So, 754₁₀ = 2F2₁₆
Hexadecimal → Decimal
Method: Multiplication by powers of 16
Convert (3A)₁₆ to decimal:
(3 × 16¹) + (10 × 16⁰)
= 48 + 10 = 58₁₀
Binary → Hexadecimal
Method: Grouping into 4 bits
Convert (11101011)₂ to hex:
Group into 4 bits: 1110 1011
1110₂ = 14₁₀ = E₁₆
1011₂ = 11₁₀ = B₁₆
Result: EB₁₆
Hexadecimal → Binary
Method: Convert each digit to 4-bit binary
Convert (7C)₁₆ to binary:
7₁₆ = 0111₂
C₁₆ = 1100₂
Result: 01111100₂
Hex Fractions
Fractions convert by multiplying/dividing by 16.
Convert (0.AC)₁₆ to decimal:
= (10 × 16⁻¹) + (12 × 16⁻²)
= (10 ÷ 16) + (12 ÷ 256)
= 0.625 + 0.046875 = 0.671875₁₀
Hexadecimal Arithmetic
Addition
Example: (2A)₁₆ + (1F)₁₆
= 42₁₀ + 31₁₀ = 73₁₀ = 49₁₆
2A
+ 1F
-----
49
1
Rightmost digits: A (10) + F (15) = 25₁₀ = 19₁₆ (write 9, carry 1)
2
Leftmost digits: 2 + 1 + carry 1 = 4 (write 4)
Result: (2A)₁₆ + (1F)₁₆ = 49₁₆
Subtraction
Example: (9C)₁₆ − (2F)₁₆
= 156₁₀ − 47₁₀ = 109₁₀ = 6D₁₆
9C
- 2F
-----
6D
1
Rightmost digits: C (12) − F (15) → borrow → 28 (12+16) − 15 = 13 (D)
2
Leftmost digits: 8 (9-1 after borrow) − 2 = 6
Result: (9C)₁₆ − (2F)₁₆ = 6D₁₆
Multiplication
Example: (B)₁₆ × (7)₁₆
B (11) × 7 = 77₁₀
Convert 77₁₀ to hexadecimal:
77 ÷ 16 = 4 remainder 13 (D)
4 ÷ 16 = 0 remainder 4
Result: (B)₁₆ × (7)₁₆ = 4D₁₆
Division
Example: (FF)₁₆ ÷ (A)₁₆
= 255₁₀ ÷ 10₁₀ = 25 remainder 5
Convert quotient to hexadecimal:
25 ÷ 16 = 1 remainder 9
1 ÷ 16 = 0 remainder 1
Quotient = 19₁₆, Remainder = 5₁₆
Result: (FF)₁₆ ÷ (A)₁₆ = 19₁₆ remainder 5₁₆
Uses of Hexadecimal
Memory Addressing
Used to represent memory addresses (e.g., 0x7FF0)
Colors in Web Design
RGB color values (e.g., #FF0000 for red)
#FF0000
#00FF00
#0000FF
Assembly/Machine Code
Easier to read and write than binary
Debugging
Hex dumps of memory/data for analysis
Example
Instead of writing 1111111100001111₂, we write FF0F₁₆ (short and clean).
Quick Conversion Chart (0–15)
Decimal Binary Octal Hex
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Summary
Hexadecimal = base 16 (0–9, A–F). It provides a compact representation of binary data.
Hexadecimal = base 16 (0–9, A–F)
1 hex digit = 4 binary digits
Conversions are simple with binary (group by 4)
Widely used in memory, colors, debugging, and programming