How Your Computer Thinks About Color

Have you ever looked at hexadecimal color codes and wondered what the logic was for that string of letters and numbers representing some color? Did you know I can count to 1,023 using only my fingers? Are you wondering what on earth these two things have to do with each other? Check this out.

You may not know this, but you’ve been living in a base 10 world your entire life. What does this mean? It means how we count and identify quantities is based around powers of 10, each digit in a number representing some number multiplied by a specific power of ten. For example, let’s look at the number 964, which has 3 digits: 9, 6, and 4. Really, the 9 represents 900, or 9*10^2. The 6 represents 60, or 6*10^1. And the 4 represents, well, 4 (or 4*10^0). Add them all together and you get 900+60+4=964. When a slot has more than 9, it rolls over to the next slot just like normal addition.

But it turns out that we don’t have to use 10 for the base; we can use any positive whole number we please. For example, I could use base 8 (or octal), in which case we only have 0, 1, 2, 3, 4, 5, 6, and 7 before we roll over to the next slot. In this case, 964 becomes 1704 or 1*8^3+7*8^2+0*8^1+4*8^0=. Anyway, if you’re wondering why I can count to 1,023 on fingers seemingly designed to count to 10, it’s because you can use binary (or base 2) on your fingers, where a raised finger represents a 1 and an unraised finger represents a 0. 

Now, what does all this mathematical babbling have to do with color? Well, because hexadecimal color codes are simply base 16 numbers, with the numbers 10-15 represented by the letters A-F. As weird as it looks, it’s a very logical system, and this great video from Nathaniel Dodson of tutvid explains exactly why. If you’re the type that likes to geek out over what goes on behind the scenes, this is for you. 

Log in or register to post comments
Elan Govan's picture

Interesting...not sure what I am going to do with all the info....but interesting just the same. No...did not fall asleep in the middle of the video.

Alex Cooke's picture

Good eye. Thanks!