Why Use Hexadecimal

From a reddit comment:

There are times when we map things to the individual bits that a number represents. This is common when interfacing with hardware but it is also seen when defining feature sets or any number of things that don’t need a large range of values.

So for example, we have a bunch of bits 7654 3210 that makes up an eight bit number. Setting bit 7 would make an LED blink and turning on bit 5 would make it shine blue. To tell the hardware this you would write the bits 1010 0000 to some address to make it happen. Writing all those ones and zeros is a pain so we use hex to shorten it. Each group of four bits represents a number from 0 to F so the above number can be expressed as 0xa0. We can quickly see that the ‘a’ part represents 1010. If we used decimal we would see the value 160 which doesn’t really relate to anything.

Tagged: programming

Last updated: