Hexadecimal numbers

Martin McBride, 2016-11-27
Tags binary hexadecimal
Categories numbers

Binary numbers can be difficult to read, and difficult to type in without error. With a long string of ones and zeros, it is very easy to make a mistake. Hexadecimal notation makes this a lot easier.

Hexadecimal is often shortened to hex.


A group of 4 bits can take any value between 0 (0000 binary) and 15 (1111 binary).

In hexadecimal, we replace each group of 4 bits with a single digit to represent the value 0 to 15. Since we only have digits 0 to 9, we use letters A to E to represent values 10 to 15. Here is a table of binary, denary and hex values:

Hex table

Hexadecimal numbers are often written in the form:


Letters are usually not case sensitive, so you can also write


Converting binary to hex

To convert the binary number 01101100 to hex:

  • Split the binary into groups of 4 bits, in this case 0110 1100
  • Look up each group in the table (binary -> hex), in this case we get 6 and C
  • Put the digits together, e.g. 0x6C

Converting hex to binary

To convert the hex number 0xfe to binary:

  • Look up each digit on the table (hex -> binary), in this case f gives us 1111, e gives us 1110
  • Join the groups of 4 bits, in this case 11111110

Copyright (c) Axlesoft Ltd 2021