1 of 16

Data Representation:

Hexadecimal Conversions

2

2 of 16

Hexadecimal Conversions

Learning Objective:

I can understand the use of hexadecimal numbers and convert between hex, binary and denary.

Learning outcome:

Successfully convert 8 bit binary to hex and back.

2

3 of 16

iCan()

iCan.Explore()

I show an understanding of the topic by briefly describing my understanding

iCan.Enhance()

I show a good technical understanding and am able to show this through detailed description and evaluation of effectiveness.

iCan.Excel()

I can show an excellent technical understanding of the topic and can give factually correct examples and evidence.

3

4 of 16

Hexadecimal (hex)

Hexadecimal is an important number system that use 16 unique digits with the denary equivalents of 10-15 being represented with letters A-F.

The most important feature of hexadecimal is that a single hex digit can be represented by exactly 4 bits.

4

5 of 16

Hexadecimal (hex)

Hex codes are used in many areas of computing to simplify binary codes. Hexadecimal is used in many areas of computers such as error messages, Mac addresses, assembly language and colours.

5

6 of 16

Hex and colours

Colour have both a hex code and an RBG value (these are both the same but written differently.

RBG requires 3 values each between 0 and 255 (exactly 8 bits) allowing us to change the amount of red, blue and green shown.

Hex codes are the same but require 3 pairs of hex values.

6

7 of 16

Bases

In order to tell the difference between number systems we given them a name and a base. The base value is how many unique digits are used in that number system.

7

Number system

Base

Unique digits

Binary

2

0,1

Denary (Decimal)

10

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

Hexadecimal (hex)

16

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

8 of 16

Binary to Hexadecimal

We can convert between multiple number system including binary to hex, hex to denary and denary to binary.

9 of 16

Binary to hexadecimal

9

Binary:

10011101

128

64

32

16

8

4

2

1

1

0

0

1

1

1

0

1

Working:

Hexadecimal:

Step 1

First write out the binary number in its 8 bit (1 byte) form

10 of 16

Binary to hexadecimal

10

Binary:

10011101

8

4

2

1

8

4

2

1

1

0

0

1

1

1

0

1

Working:

Hexadecimal:

Step 2

Now instead of treating it like an 8 bit (1 byte) form we are going to split it into two 4 bit numbers known as nibbles

11 of 16

Binary to hexadecimal

11

Binary:

10011101

8

4

2

1

8

4

2

1

1

0

0

1

1

1

0

1

Working:

8+1 = 9 8+4+1=13

Hexadecimal:

Step 3

The next step is to work out what the two smaller binary numbers represent (out of 16).

12 of 16

Binary to hexadecimal

12

Binary:

1001 1101

8

4

2

1

8

4

2

1

1

0

0

1

1

1

0

1

Working:

9 turns into 9 13 turns into D

Hexadecimal:

9D

Steps

  1. Split the binary number in half
  2. Convert each side as a 4 bit number
  3. If any of the results are between 10-15, convert to a letter
  4. Put the two values together

13 of 16

Hexadecimal to Binary

14 of 16

Hexadecimal to Binary

14

Hexadecimal:

A5

8

4

2

1

8

4

2

1

Working:

A = 10 5 = 5

Binary:

Step 1

To convert from hexadecimal to binary you first need to work out what each of the values is representing in decimal out of 15.

15 of 16

Hexadecimal to Binary

15

Hexadecimal:

A5

8

4

2

1

8

4

2

1

1

0

1

0

0

1

0

1

Working:

A = 10 = 1010 5 = 5 = 0101

Binary:

Step 2

You must then represent those small decimal numbers in their binary form as nibbles

16 of 16

Hexadecimal to Binary

16

Hexadecimal:

A5

8

4

2

1

8

4

2

1

1

0

1

0

0

1

0

1

Working:

A = 10 = 1010 5 = 5 = 0101

Binary:

10100101

Step 3

Then just write the two nibbles out as a single byte of data and you are done