Before we move on, I want to be very clear.

Computers do not work in hex. Your computer’s central processing unit (CPU) only recognizes two states – ON and OFF. It is the foundation for all binary code, which is used in all computer and digital systems.

So then Clyde, why do we use hex? And why has the internet community decided that URLs should work in hex?

The main reason why we use hex is because it provides a more human-friendly representation than other systems. In other words, it’s much easier to express binary numbers in hex than it is in any other base number system.

Let’s look at an example of a byte (because as you know, computers speak in binary).

1 byte = 8 bits. This means 1 byte can store the values from 0 to 255 (0000 0000 to 1111 1111 in binary). As I’m sure you can see, expressing numbers in binary is not easy for us. Imagine having to tell your mate that your mobile number is 1001 1111 1010 0101 ... you get the idea.

Since a byte is 8 bits, it makes sense to divide that up into two groups, the top 4 bits and the low 4 bits. With 4 bits, it is possible to create 16 different values (0-15). This means a base 16 system will be easier to work with.

And this is where hex comes into the picture.

Each hexadecimal digit represents four binary digits. For example, a single byte can have values ranging from 0000 0000 to 1111 1111 in binary form, but in hex this can be represented as 00 to FF.

As the saying goes, a picture is worth a thousand words. Looking at the below picture, you can be the judge of deciding which numbering system is easier to work with.

Hex vs Binary system

Now the advantages over decimal vs hex becomes apparent when dealing with very large numbers. For example, the decimal number 1,000,000 has 7 digits right? But in hex this is represented as F4240, which is only 5 digits. Less is more :)

Bottom line: working in hex is easier than working in other numeric systems.

Got it? 

Great. See you in the next lecture.