0% found this document useful (0 votes)
20 views73 pages

Lesson 4 - Hexadecimal

Uploaded by

Ali Papila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views73 pages

Lesson 4 - Hexadecimal

Uploaded by

Ali Papila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 73

Computing

Lesson 4: Hexadecimal

Data representation

Ali Papila
In this lesson you will:

Explain how numbers are represented using


hexadecimal

Convert decimal numbers to and from


hexadecimal

Explain why and where hexadecimal notation


is used

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

Hexadecimal is a base 16 number system.

How many digits do you think it has?


16!

7
Hexadecimal

The digits used for hexadecimal are;

0, 1, 2, 3, 4, 5, 6, 7,

8, 9, A, B, C, D, E, F

8
Hexadecimal

The digits used for hexadecimal are;

0, 1, 2, 3, 4, 5, 6, 7,

8, 9, A, B, C, D, E, F

Note that it uses the letters A - F to represent 10 - 15.

9
Hexadecimal

Hexadecimal is often used instead of binary because it


is:
A1
● Easier to read and interpret
10100001
● It uses fewer digits to represent the same value
● Compared to binary, it is less likely that a digit will
be written down incorrectly

10
Hexadecimal
x 16 x 16 x 16

You work out the place value by multiplying by 16 as 4096 256 16 1


you move from right to left.

11
Converting from hexadecimal to decimal

If you wanted to convert a hexadecimal value into 4096 256 16 1


decimal then you could follow the same rules as we A 1
had with binary.

12
Converting from hexadecimal to decimal

If you wanted to convert a hexadecimal value into 4096 256 16 1


decimal then you could follow the same rules as we A 1
had with binary. 16 x 10 1x1

13
Converting from hexadecimal to decimal

If you wanted to convert a hexadecimal value into 4096 256 16 1


decimal then you could follow the same rules as we A 1
had with binary. 16 x 10 1x1
160 1

14
Converting from hexadecimal to decimal

If you wanted to convert a hexadecimal value into 4096 256 16 1


decimal then you could follow the same rules as we A 1
had with binary. 16 x 10 1x1
160 1

A1 in hexadecimal is 161 in decimal.

15
Converting from decimal to hexadecimal

Again, converting from decimal to hexadecimal is a 4096 256 16 1


little like when we converted from decimal to binary.

However, the maths can be a little more challenging.

16
Converting from decimal to hexadecimal

Let’s take the decimal value 180 and convert it to 4096 256 16 1
hexadecimal.

Remember, we are working with 16 digits now and not


just 2 so there are extra steps to take.

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.

Remember this isn’t binary.

We need to know how many times 16 goes into 180.

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.

Remember this isn’t binary.

We need to know how many times 16 goes into 180.

16 1 8 0

20
Converting from decimal to hexadecimal

Does 16 go into 1? 4096 256 16 1

16 1 8 0

21
Converting from decimal to hexadecimal

Does 16 go into 1? 4096 256 16 1

No

16 1 8 0

22
Converting from decimal to hexadecimal

Does 16 go into 18? 4096 256 16 1

16 1 8 0

23
Converting from decimal to hexadecimal

Does 16 go into 18? 4096 256 16 1

Yes, once

1
16 1 8 0

24
Converting from decimal to hexadecimal

With 2 remaining 4096 256 16 1

1
16 1 8 2
0

25
Converting from decimal to hexadecimal

Does 16 go into 20? 4096 256 16 1

1
16 1 8 2
0

26
Converting from decimal to hexadecimal

Does 16 go into 20? 4096 256 16 1

Yes once, with 4 remaining

1 1
16 1 8 2
0 4

27
Converting from decimal to hexadecimal

So 16 goes into 180 11 times with 4 remaining. 4096 256 16 1

1 1
16 1 8 2
0 4

28
Converting from decimal to hexadecimal

11 in hexadecimal is represented by a B so we add a B 4096 256 16 1


to the 16 column. B

1 1
16 1 8 2
0 4

29
Converting from decimal to hexadecimal

4 is remaining, this is already a hexadecimal digit so 4096 256 16 1


we add this here. B 4

1 1
16 1 8 2
0 4

30
Converting from decimal to hexadecimal

180 in decimal is B4 in hexadecimal. 4096 256 16 1


B 4

31
Converting from decimal to hexadecimal

180 in decimal is B4 in hexadecimal. 4096 256 16 1


B 4

Note that calculators are not allowed in your


examination so you would need to do all of this in your
head.

32
There must be a better way!

33
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

34
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

Each of these sections would take up 1 byte of storage. This only works with values up to 1 byte.

35
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

2 hexadecimal values use 1 byte of storage

36
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

2 nibbles (a nibble is half a byte) is equivalent to 1 byte of storage.

37
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

8 bits is equivalent to 1 byte of storage.

38
The better way!

Draw these two tables:

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

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

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

40
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2

41
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010

42
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010 0010

43
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010 0010 1 0 1 0

44
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010 0010 1 0 1 0 0 0 1 0

45
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010 0010 1 0 1 0 0 0 1 0

46
Hexadecimal to decimal

Convert A216 to decimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


A2 1010 0010 1 0 1 0 0 0 1 0 162

47
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

48
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


180

49
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 180

180 - 128 = 52

50
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 0 180

180 - 128 = 52

51
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 0 1 180

180 - 128 = 52

52
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 0 1 180

180 - 128 = 52
52 - 32 = 20

53
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 0 1 1 180

180 - 128 = 52
52 - 32 = 20
20 - 16 = 4

54
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 0 1 1 0 1 0 0 180

180 - 128 = 52
52 - 32 = 20
20 - 16 = 4

55
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1011 1 0 1 1 0 1 0 0 180

56
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1011 0100 1 0 1 1 0 1 0 0 180

57
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


B 1011 0100 1 0 1 1 0 1 0 0 180

58
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


B4 1011 0100 1 0 1 1 0 1 0 0 180

59
Decimal to hexadecimal

Convert 18010 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


B4 1011 0100 1 0 1 1 0 1 0 0 180

60
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC

61
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1 1 1 1 1 1 1 1

62
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1111 1 1 1 1 1 1 1 1

63
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


1111 1111 1 1 1 1 1 1 1 1

64
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


F 1111 1111 1 1 1 1 1 1 1 1

65
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


FF 1111 1111 1 1 1 1 1 1 1 1

66
Binary to hexadecimal

Convert 111111112 to hexadecimal

A B C D E F
10 11 12 13 14 15

HEX 8421 8421 128 64 32 16 8 4 2 1 DEC


FF 1111 1111 1 1 1 1 1 1 1 1

67
Conversions: try it yourself!

Decimal to hexadecimal: Hexadecimal to binary:

A.190 A.8A
B. 65 B. 4F
C. 230 C. 33

Hexadecimal to decimal: Binary to hexadecimal:

D.A3 D.11001100
E. F2 E. 00001111
F. 1D F. 11110000

68
Conversions: solutions

Decimal to hexadecimal: Hexadecimal to binary:

A.190 BE A.8A 10001010


B. 65 41 B. 4F 01001111
C. 230 E6 C. 33 00110011

Hexadecimal to decimal: Binary to hexadecimal:

D.A3 163 D.11001100 CC


E. F2 142 E. 00001111 0F
F. 1D 29 F. 11110000 F0

69
Where might you see hexadecimal values?

HTML code

<h1 style="background-color:#B827EB;">

This is electric purple

</h1>

70
Where might you see hexadecimal values?

MAC addresses

71
Where might you see hexadecimal values?

Memory dumps

Source: Wikipedia, By I, Mwtoews

72
Where might you see hexadecimal values?

Picking colours

Source: Google slides colour picker

73

You might also like