Lesson 4 - Hexadecimal
Lesson 4 - Hexadecimal
Lesson 4: Hexadecimal
Data representation
Ali Papila
In this lesson you will:
2
Binary?
Base 10 Base 2
3
Binary?
Base 10 Base 2
4
How many digits does
decimal have?
10 2
5
How many digits does
decimal have?
10 2
6
Hexadecimal
7
Hexadecimal
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E, F
8
Hexadecimal
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E, F
9
Hexadecimal
10
Hexadecimal
x 16 x 16 x 16
11
Converting from hexadecimal to decimal
12
Converting from hexadecimal to decimal
13
Converting from hexadecimal to decimal
14
Converting from hexadecimal to decimal
15
Converting from decimal to hexadecimal
16
Converting from decimal to hexadecimal
Let’s take the decimal value 180 and convert it to 4096 256 16 1
hexadecimal.
17
Converting from decimal to hexadecimal
Firstly, 256 will not go into 180 so we know that we 4096 256 16 1
don’t need that column.
18
Converting from decimal to hexadecimal
16 does go into 180 but we don’t just simply put a 1 4096 256 16 1
there because that wouldn’t work.
19
Converting from decimal to hexadecimal
16 does go into 180 but we don’t just simply put a 1 4096 256 16 1
there because that wouldn’t work.
16 1 8 0
20
Converting from decimal to hexadecimal
16 1 8 0
21
Converting from decimal to hexadecimal
No
16 1 8 0
22
Converting from decimal to hexadecimal
16 1 8 0
23
Converting from decimal to hexadecimal
Yes, once
1
16 1 8 0
24
Converting from decimal to hexadecimal
1
16 1 8 2
0
25
Converting from decimal to hexadecimal
1
16 1 8 2
0
26
Converting from decimal to hexadecimal
1 1
16 1 8 2
0 4
27
Converting from decimal to hexadecimal
1 1
16 1 8 2
0 4
28
Converting from decimal to hexadecimal
1 1
16 1 8 2
0 4
29
Converting from decimal to hexadecimal
1 1
16 1 8 2
0 4
30
Converting from decimal to hexadecimal
31
Converting from decimal to hexadecimal
32
There must be a better way!
33
The better way!
A B C D E F
10 11 12 13 14 15
34
The better way!
A B C D E F
10 11 12 13 14 15
Each of these sections would take up 1 byte of storage. This only works with values up to 1 byte.
35
The better way!
A B C D E F
10 11 12 13 14 15
36
The better way!
A B C D E F
10 11 12 13 14 15
37
The better way!
A B C D E F
10 11 12 13 14 15
38
The better way!
A B C D E F
10 11 12 13 14 15
The decimal values that we will be using will always be less than 256, this means that they take up
1 byte of storage.
39
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
40
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
41
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
42
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
43
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
44
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
45
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
46
Hexadecimal to decimal
A B C D E F
10 11 12 13 14 15
47
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
48
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
49
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
50
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
51
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
52
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
52 - 32 = 20
53
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
52 - 32 = 20
20 - 16 = 4
54
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
180 - 128 = 52
52 - 32 = 20
20 - 16 = 4
55
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
56
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
57
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
58
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
59
Decimal to hexadecimal
A B C D E F
10 11 12 13 14 15
60
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
61
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
62
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
63
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
64
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
65
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
66
Binary to hexadecimal
A B C D E F
10 11 12 13 14 15
67
Conversions: try it yourself!
A.190 A.8A
B. 65 B. 4F
C. 230 C. 33
D.A3 D.11001100
E. F2 E. 00001111
F. 1D F. 11110000
68
Conversions: solutions
69
Where might you see hexadecimal values?
HTML code
<h1 style="background-color:#B827EB;">
</h1>
70
Where might you see hexadecimal values?
MAC addresses
71
Where might you see hexadecimal values?
Memory dumps
72
Where might you see hexadecimal values?
Picking colours
73