What is a Hexadecimal?

532 viewsMathematicsOther

I was looking at a web page listing specific colors and it had a spot next to each color listing a Hexadecimal. What the hex is a Hexadecimal? I did google it but have math dyslexia (dyscalculia) so had trouble understanding. Grazie.

In: Mathematics

10 Answers

Anonymous 0 Comments

In the simplest possible terms, a hexadecimal is just a number: each color a computer can display has a number that describes it.

To add a little more detail: each color a computer can display is made by mixing together varying amounts of red, green, and blue, similar to how you can make different colors by mixing paint. If you have no red, green, or blue, you get black, if you have the max of all of them, you get white. Lots of red and green but little blue give you yellow, etc. So, what’s called the hex is really three numbers, one describes the amount of red, one describes the amount of green, and one describes the amount of blue. It might not look like three numbers because we smoosh them all together, and especially because it sometimes has letters, too, but that’s what it is.

Ok, so why do we use that funny format that includes letters? Suppose each color channel (red, green, or blue) could take on 100 different values. We could write them like 00, 01, 02 … 99. This has the benefit that every value uses exactly two digits, and everything you can write with two digits corresponds to a valid color. So, you could smoosh them together like 990099 to represent magenta with the max amount of red and blue and no green. Suppose instead each color channel could take 150 different values. This is much more cumbersome: for most numbers you want to write, you need a leading zero like 042, and other things you could write like 320 are outside the valid range of values. You could make this work, but there’s clearly lots more chance for mistakes and ambiguities.

Well, for technical reasons the color channels each can take on 256 different values. Is there a nice way we could write them down that gives us the same benefits and the 100 value case, where we always use the same number of digits, and everything you can write using those digits is a valid value? It turns out there is. The trick is that we extend what we can write using one digit by adding A through F as valid digits. This means that ten is written as A, eleven is written as B, up through fifteen being written as F. After that, we carry over to the next digit just like normal: sixteen is written 10, seventeen as 11 and so on. If you keep going, you find that one hundred fifty is written A0, all the way until two hundred fifty five is written as FF. This gives us what we want two hundred fifty six values, 00 to FF, all written using exactly two digits, with every two digit number corresponding to value within the valid range. Smoosh three of these together for each color channel, add a # to make it clear you’re using this funny format and you get #000000 for black, #FFFFFF for white, #00FF00 for green, #FF00FF for magenta, and everything else in between.

You are viewing 1 out of 10 answers, click here to view all answers.