Hexadecimal Numbers

Hexadecimal numbers are base 16.

There are 16 different hex digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, or f

Hex Digit0123456789abcdef
Decimal Value0123456789101112131415
Binary Value0000000100100011010001010110011110001001101010111100110111101111

Place Value Table

161160
161

Example 1: Convert the hex number 5e to decimal.

Step 1: Multiply each hex digit by its place value.

Step 2: Add the resulting numbers.

161
5e
5 × 16 = 8014 × 1 = 15
80  + 15 =    95

Example 2: Convert the 4-bit binary number 1110 to hex.

Find the hex digit by looking it up in the table.

1110 = e


Example 3: Convert the 8-bit binary number 01101110 to hex.

Step 1: Separate the binary digits into groups of 4:     01101110
Step 2: Convert each group of digits to hex:     6e

01101110 = 6e


Example 4: Convert the hex number 8f to binary.

Look up each hex digit in the table, and write its binary value.

hex 8 = 1000

hex f = 1111

Therefore, 8f = 10001111


We use hexadecimal to represent numbers because it is:
a) easy to convert hex to binary,
b) easy to convert binary to hex,
c) easier to read 2 digits than 8 digits.

Computer Programming Unit 2.2 - How Hexadecimal Numbers are Used in Computers