What is Hexadecimal?

Hexadecimal (or hex) is a base 16 system used to simplify how binary is represented. A hex digit can be any of the following 16 digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F.

Each hex digit reflects a 4-bit binary sequence.

This means an 8-bit binary number can be written using only two different hex digits – one hex digit for each nibble (or group of 4-bits). It is much easier to write numbers as hex than to write them as binary numbers.

For example:

  • 11010100 in binary would be D4 in hex
  • FFFF3 in hex would be 11111111111111110011 in binary

This table shows each hex digit with the equivalent values in binary and denary.

Denary Binary Hexadecimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

Hex codes are used in many areas of computing to simplify binary codes. It is important to note that computers do not use hexadecimal – it is used by humans to shorten binary to a more easily understandable form. Hexadecimal is translated into binary for computer use. Some examples of where hex is used include:

  • Colour references
  • Assembly language programs
  • Error messages

Binary to Hexadecimal Conversion

To represent the denary number 12 in a computer system, you could use binary 1100 or hex value C.

To convert a 4-bit binary number to hex:

Binary Denary Hex
1100 (1×8) + (1×4) + (0x2) + (0x1) = 12 C

 

A byte is made of eight binary digits. To convert an 8-bit binary number to hex, separate it into two nibbles or two half-bytes.

Binary Denary Hex
1011 1001 11 and 9 B9

Hexadecimal to Binary Conversion

Separate the hex digits to find each equivalent in binary, and then piece them back together.

What is the denary value of hex value 2D?

Separate the hex digits into 2 and D and find the equivalent binary numbers (2 = 0010; D = 1101).

Piece them together to get 00101101 (0x128 + 0x64 + 1×32 + 0x16 + 1×8 + 1×4 + 0x2 + 1×1 = 45 in denary)

The below worksheet shows some of the conversion that were done during the SKE.

Hexadecimal Worksheet