We use base 10 for counting. we add a new digit to a number every 10 numbers. at 10 we add the ten’s place. At 100 we add the 100’s place.
Hexadecimal is base 16. It has 16 values in the 1’s place (1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) and then we add another digit.
F in hexidecimal is 15. 10 is 16.
This numbering system exists because computers are built around switches that can take on 2 states. If you use 4 switches they can take on 16 states.
Computers are binary devices. 0 and 1 are the building blocks of storing and manipulating data.
Unfortunately, with only 2 digits to choose from, numbers get wide really fast. The number 120 in binary is 1111000, and it can get hard to read. Did I type 7 or 8 digits in that number?
Hexadecimal is an alternative number system again. In binary, when counting we need a new digit at merely two, getting “10”. In decimal, the regular human number system, the “10” number represents ten. Hexadecimal carries at sixteen (16), “hex” meaning 6, and “decimal” being 10, hence the name. For the numbers 10 through 15 we use the letters A through F to represent them, so counting goes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10. The last number on that list is sixteen.
The advantage for computers and binary work is that a single hexadecimal digit exactly corresponds to 4 binary digits. Hexadecimal digit 0 corresponds to 0000 and F corresponds to 1111 in binary. In fact a byte is always exactly 2 hexadecimal digits, and the number range from 00000000 to 11111111 is the same as the range from 00 to FF.
So, you can work with hexadecimal and make your binary data generally easier to read, a lot less wide, etc. Looking at anything digital in actual binary is kinda rare nowadays.
u/lollersauce914 has a great response, but I’ll just provide some color commentary
Hex = 6 and decimal = 10, hence hexadecimal = a counting system based on 16s.
Now, separate the idea of “a number” from the symbol we use to write the number.
Whether you call it 3 vs III, or Three, or Tres, or Drei, or glurbby, the idea of “3” things never changes, but we can use different symbols and words to name it.
The problem with eleven is our symbol, 11, is actually two symbols in a row. What if you only have one space to write eleven? Well, you couldn’t do it. That’s kind of our computer problem, we want to write eleven all the time, but we only have one space for it. So computer programs took the symbol for the letter A and just said, “Ok, but when we use ‘A’ as a number, it stands for “11””. So now we can write eleven in a single space, a. similar 12 is b, 13 is c.
Here is where it gets a bit weird though, if F is 16, how do we write 17?
How do we do it normally? You put the ones spot back to ‘1’ and start counting again with a ‘1’ in the tens spot. (note that hexadecimal doesn’t use the symbol “0”)
so it goes A=10, B=11…E = 15, F = 16, **11 = 17, 12 = 18, 13= 19…. 1A = 26, 1B = 27, 1C = 28… 32 = 20, 33 = 21.**
“Normal” math is “base 10”. That means it uses 10 values (0 1 2 3 4 5 6 7 8 9), and the digits of a number show powers of 10 (a 10s digit, a 100s digit, a 1000s digit, etc).
“367” in base 10 means “3x 100s, and 6x 10s, and 7x 1s”.
Hexadecimal uses 16 values instead (0 1 2 3 4 5 6 7 8 9 A B C D E F), and the digits of a number show powers of 16 (a 16s digit, a 256s digit, a 4096s digit, etc).
“367” in hexadecimal means “3x 256s, and 6x 16s, and 7x 1s”.
Easy version: It’s a kind of number that can have digits 0-9 and also the letters A-F. Examples: 11, 59, B6, F1. For specifying colors you don’t need to know how to do math with hexadecimal numbers, just copy/paste the number where you need it. Just think of it as a nickname for the color.
More complete version: It’s a number system that has 16 digits 0123456789ABCDEF instead of our usual 10 digits. A=10 and F=15. A number with more than one digit like B9F2 has a 4096s-place, 256s-place, a 16s-place and a ones-place, similar to how usual decimal numbers have a ten-thousands place, thousands place, a hundreds place and a ones place. So B9F2 = 11*4096 + 9*256 + 15*16 + 2 = 47,602
The reason it exists is because it is easier to work with how computers store numbers internally in hexadecimal than in decimal, when doing low level computer work. Hexadecimal “fits” better with how computers store numbers.
Hexadecimal is base 16, so instead of numbers going from 0 to 9 like decimal (base 10, i.e. normal numbers), they go from zero to 15, with the six remaining numbers above nine being a through f. The first digit is multiplied by 16 to the zero, or 1. The second digit is multiplied by 16 to the 1st or 16. So 10 in hexadecimal is 16. The third digit is multiplied by 16 to the 2nd, or 256, so 100 in hexadecimal is 256. The Fourth digit would be 4,096, and the 5th digit would be 65536, etc. decimal works the same way, but using 10 instead of 16.
Hex is just another notation using not only numbers but also letters (from A to F). So you start off at 0 in both systems (dec and hex) up to 9 and they’re the same. Except decimal has to roll over at that point and add a new number. So you end up with 10. Hex had a trick up its sleeve: once the numbers end, it goes to A. So A in hex is 10 in dec.
Now, in computing a byte can have 256 possible values, from 0 to 255. In hex that’s 0 to FF.
And we finally get to colours. A colour is made up of combinations of Red, Green and Blue, each component having one byte assigned as its value. So 0-255 (or 0-FF). So if your colour is full red, it would be a completely “lit” red value and nothing on green and blue. So 255,0,0 or FF0000. Same goes for a full green (0,255,0/00FF00) or blue. A complete black has 0 on all the values (000000) while a full white has 255 on all values, or FF (so FFFFFF) with shades of grey inbetween (they need to have equal values on all rgb components). However, a full magenta would contain red and blue and no green, so FF00FF (255,0,255).
As you play with this spectrum you can obtain different colours and shades.
That’s it, in a nutshell.
hexadecimal means 16 based (hex=6 and decimal=10)
we normally use a decimal system, meaning that when counting with your fingers for instance you can reach up to ten, using one set of fingers (usually…). but what do you do when you want to represent the number 31, for instance?
ofcourse you keep in mind, that you have one set of hands full already, so lets mark that down as a 1×10 fingers, after which you still have to count another two full set of hands, as well as one remaining finger. in written form it looks like this:
set of hands fingers
(x10) ( x1)
3 1
resulting in 31 in decimal counting.
Now imagine a creature that has 16 fingers per set of Hands… for them the number 18 would mean one full set of hands and 15 remaining fingers:
set of hands fingers
(x16 ) ( x1)
1 15
resulting in 115 in hexadecimal counting? no, that cant possibly be right, huh? we need a way of representing 15 as a single sign…..
Now comes the weird part: since most humans count with a base of ten, we use numbers that can depict that range perfectly: 0-9
But our 16-fingered creature would, ofcourse need numbers that can depict the numbers from 1-16, right?
to “fake” our way around that, when we write down numbers in hexadecimal form we simply take a few letters and give them the meaning of:
a=10
b=11
c=12
d=13
e=14
f=15
using this bigger range of symbols, the
31 in decimal
(3×10 + 1)
would correctly be written as
1f in hexadecimal
(1×16 + f)
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.
Latest Answers