Tutorial: Hexadecimal

Read more “Tutorial: Hexadecimal”

Hexadecimal is a numeral system commonly used by computers. For example, when showing information from its memory in low-level programming languages such as C++ or even assembly language. In other words, whenever you get really close to the metal.

But it’s not just used in programming languages. Some software editors may also visualize all the data in hexadecimal values to present the information. This could be because of displaying a chunk of memory or a hard disk sector, or because you are editing data at a level where it just makes more sense due to the way the individual bits of these numbers are grouped by the hardware registers of a computer.

We humans are used to base 10 numbers. We are so used to it that explaining how to count from 0 to 9 then from 10 to 19 seems so very obvious. But for a computer, base 16 makes a lot more sense. Here you are counting from 0 to 9, continuing with A to F for values 10 to 15, then only bumping to 10 at that point. At this point, 10 means 16. It can be confusing, so low-level programmers added a designation to clearly differentiate hexadecimal from decimal. This can vary depending on the language and the origin. In old home computers, hexadecimal 10 is typically shown as $10. In C and C++, it is shown as 0x10.

But why does it make sense to use base 16 instead of base 10?