What is hexadecimal?

Hexadecimal is a number system which is often used by programmers to simplify the binary numbering system. You can represent very large numbers in hexadecimal in a way that’s much easier for humans to read large numbers. It is also easy to convert between hexadecimal and binary as we will see later.

Picture

Here are some genuine order numbers from my visit to McDonald’s. They are either:

  • Hexadecimal - used for Uber and Deliveroo drivers. These have five digits and may contain letters.
  • Decimal – used for in store customers. These have three digits long.

How does hexadecimal work?

Our number system is decimal or base 10. Thus means that to make any number we can use a combination of up to 10 numbers: 0,1,2,3,4,5,6,7,8 and 9.

Hexadecimal is base 16 which means that to make any number we can use a combination of up to 16 alphanumeric characters (numbers or letters).

We start as normal: 0123456789. When we run out of numbers we use the first letters of the alphabet: a represents 10, b represents 11 and so on until we get to f which represents 15. See the image on the right.

Picture

Picture


Hexadecimal to Decimal

To convert a hexadecimal number to decimal we carry out the following steps:

  1. Write out the number line. See the first row below. We start with 1 on the right, then multiply by our base (16) to work out the other numbers.
  2. Write out the hexadecimal number to convert. I have chosen the first McDonald's order: becbe.
  3. Convert the numbers into normal numbers.
  4. Multiply the normal number with the top line. As you can see below 11 * 65,536 = 720,896.
  5. Add all the results together.

Picture


Representing Colours in Hexadecimal

Picture

You will often see colours represented as hexadecimal. You will know because they start with a # sign. For example #FF 00 00 is the colour red, Colours are made up of three primary colours: red, green and blue. Think of this as three buckets of paint which are mixed together to make any colour. A full bucket of paint has the value 255 in decimal and FF in hexadecimal. To show a colour value you have to say how much of each colour you want. So RGB(255,0,0) or #FF0000 is red.

Note: you must give a value for red, green and blue even if you just want to add one of the colours.

Check the colour wheel below for some examples. Colours in between red, green or blue are the result of mixing. So yellow is made by mixing a bucket of red and a bucket of green.

Picture

Colour sare made by mixing red, green and blue. 255 is a full bucket of paint. So 127 is half a bucket of paint.

Picture

Picture

Hexadecimal Colour Picker.

If you are feeling brave you can work out your own hexadecimal colour values. Or you can use this website.