The hexadecimal or base-16 numbering system is commonly used as a condensed representation of a binary number, since each hexadecimal digit is equivalent to four binary digits.

The main characteristics of the hexadecimal numbering system are that:-

• each digit varies in the range 0 to 15,
• moving to the left, each digit is worth sixteen times as much as the digit immediately to its right.

The octal or base-8 numbering system is an alternative to hexadecimal, in which each octal character is equivalent to three binary digits.

A single hexadecimal digit may take any value between 0 and 15. Numbers 0–9 are used as in the decimal system, while values in the range 10–15 are represented by letters of the alphabet A, B, C, D, E and F, as shown in the following table.

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

## Converting Between Binary and Hexadecimal

Conversion between binary and hexadecimal is based on swapping groups of 4-bits with the equivalent hexadecimal digit. Unfortunately, there is no easy way to remember the associated 4 bit binary codes for the letters A to F, other than regular practice. However, the above table may easily be drawn from first principles, if required.

#### Binary to Hexadecimal Conversion

When converting between the binary and hexadecimal numbering systems, each group of 4 bits starting at the right hand side is converted into a single hexadecimal digit. This approach is illustrated by the following example, which converts the binary number 111 1010 1100 11102 giving the result 7ACE16.

#### Hexadecimal to Binary Conversion

To convert a hexadecimal number to binary, each hexadecimal digit is replaced by the equivalent 4-bit code. The following example converts the hexadecimal number 4FD716 to binary, giving the result 100 1111 1101 01112.

See the Numbering Systems Problems page for additional practice activities. Windows users may check their results by using the Windows Calculator in programmer’s view.