# Evaluating the 8-Bit Hexadecimal RBG Color Model

Here’s a fun exercise: how does the computer know what color a 6 digit hex code should represent? In computing, you will often encounter values in base 16, or hexadecimal. In this base system, a single digit can represent values from 0 to 15. An immediate problem would be representing a value greater than 10 in a single digit. Here is where we enlist the alphabet to help us. 10_{10} is written as A_{16}, 11_{10} as B_{16}, 12_{10} as C_{16}, 13_{10} as D_{16}, 14_{10} as E_{16}, and 15_{10} as F_{16}. As the base increases, we enlist more help from the alphabet (and beyond). Read this post on numeric bases if you need a quick primer.

Now, let’s look at the 8-bit hex code color pallet. The RGB model can be represented as (x, y, z), where x, y, and z are integers from 0 to 255. Why 255? To answer that, let’s first think about what 8-bit means. One bit is the smallest unit of storage, on and off, which can be represented as 0 and 1. If we combine 8 of them together, for example 10101010, we will have 8 slots of storage. It’s starting to look awfully like a binary number, and it technically is! We can interpret this 8-bit storage as a binary number, in this case it’s 170_{10}. The maximum binary value we can represent in 8-bit is 11111111_{2}, or 255_{10}.

We can further reduce this 8-bit storage into something more manageable: two hexadecimal digits. In the case of 10101010_{2}, it’s hexadecimal value is AA_{16}. Finally, we can look at the hex code colors. To display the color white, we set the three primary colors to the max value. The hex code for this is #FFFFFF. We can evaluate #FFFFFF as (FF_{16},FF_{16},FF_{16}), or (255_{10}, 255_{10}, 255_{10}). We can see now that this hex code is encoded with the 8-bit value for the three primary colors red, green, and blue, respectively. #FF0000 will be evaluated as (255, 0, 0), which sets the color red to it’s max value, and the rest to 0. What then, will #028482 produce?