Converting hexadecimal

To convert denary numbers to hex, you need to remember the equivalent binary numbers for the first 16 hex digits.

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:

BinaryDenaryHex
1100(1x8) + (1x4) + (0x2) + (0x1) = 12C

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.

BinaryDenaryHex
1011 100111 and 9B9

There are two methods of converting hex to denary:

Method 1: Converting from hex to denary via binary

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

Worked example - What is the denary value of hex value 2D?

  1. Separate the hex digits into 2 and D and find the equivalent binary numbers (2 = 0010; D = 1101).
  2. Piece them together to get 00101101 (0x128 + 0x64 + 1x32 + 0x16 + 1x8 + 1x4 + 0x2 + 1x1 = 45 in denary).

Method 2: Using base 16 place-value columns

Another method is to create base 16 place-value columns, and add the hex value to the appropriate columns. You would then need to work out what the hex digits represent in denary, and multiply this figure with the place-value. Finally, add all the values together.

The base 16 columns would be (161=16), (162=256), (163=4096), etc.

Worked example - What is the denary value of hex value 2D?

A hexadecimal table
  1. Add the hex value to the appropriate base 16 place-value column: 2 in the 16 column; D in the 1 column.
  2. Work out what the hex digits represent in denary: 2 = 2 in denary; D = 13 in denary.
  3. Multiply this figure with the place value: 2 x 16 = 32; 13 x 1 = 13.
  4. Add the values together: 32 + 13 = 45 in denary.