Data representation - EduqasHexadecimal

Binary data can represent numbers, graphics, sound and characters. It is then organised and manipulated differently. Data can also be stored in arrays, records or external files and go through validation or verification checks to ensure accuracy.

Part ofComputer ScienceUnderstanding Computer Science

Hexadecimal

Converting between binary and hexadecimal numbers

In computer science, different number bases are used to represent numbers:

  • is base 10, which has ten symbols (0,1,2,3,4,5,6,7,8,9)
  • is base 2 , which has two symbols (0,1)

, also known as hex, is also used. It has 16 symbols – the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 and the capital letters A, B, C, D, E and F.

DenaryBinaryHexadecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F
Denary0
Binary0000
Hexadecimal0
Denary1
Binary0001
Hexadecimal1
Denary2
Binary0010
Hexadecimal2
Denary3
Binary0011
Hexadecimal3
Denary4
Binary0100
Hexadecimal4
Denary5
Binary0101
Hexadecimal5
Denary6
Binary0110
Hexadecimal6
Denary7
Binary0111
Hexadecimal7
Denary8
Binary1000
Hexadecimal8
Denary9
Binary1001
Hexadecimal9
Denary10
Binary1010
HexadecimalA
Denary11
Binary1011
HexadecimalB
Denary12
Binary1100
HexadecimalC
Denary13
Binary1101
HexadecimalD
Denary14
Binary1110
HexadecimalE
Denary15
Binary1111
HexadecimalF

Hexadecimal is useful because large numbers can be represented using fewer digits.

Additionally, hexadecimal is easier to understand than binary. Programmers often use hexadecimal to represent binary values as they are simpler to write and check than when using binary.

Hexadecimal to denary

Whereas denary place values are powers of 10, and binary place values are powers of 2, hexadecimal place values are powers of 16. The first five hexadecimal place values are 65,536, 4,096, 256, 16 and 1.

Each place value can be represented by the symbols 0 through to F.

To convert hexadecimal to denary, take each place value that has a unit in it and add them together.

Example - hexadecimal 7C

Place value65,5364,096256161
Value7C
Place valueValue
65,536
4,096
256
167
1C

Result: (7 × 16) + (C × 1) = (7 × 16) + (12 × 1) = (112) + (12) = 124

Question

What would these hexadecimal numbers be in denary?

  • 11
  • 2B
  • FA

Denary to hexadecimal

  • If the denary number is bigger than 16, divide it by 16. Take the hexadecimal equivalent of this result - this represents the first digit. Take the hexadecimal equivalent of the remainder - this represents the second digit.
  • If the denary number is smaller than 16, take the hexadecimal equivalent of the denary number.

Example - convert denary 22 to hexadecimal

16 goes into 22 once with 6 left over, so 22 ÷ 16 = 1 remainder 6

1 = hexadecimal 1

6 = hexadecimal 6

Result: 16

Example - convert denary 138 to hexadecimal

138 ÷ 16 = 8 remainder 10

8 = hexadecimal 8

10 = hexadecimal A

Result: 8A