.: Home : Fragments of theory : From decimal to hex :.
From decimal to hexadecimal:
Before understanding the hex color code which is the color code used in html,
one should learn about the hexadecimal number
system which makes up the hex color code.
It's not too complicated to understand and it's a nice thing to know!
In the decimal system we have 10 different characters which make up our number
alphabet (ie. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9). If we want to go one number
higher then 9 (or 09) we change the second digit to a 1 and reset the first
digit to 0! This is all pretty straight forward!
In hexadecimal, there are 16 sign in the number alphabet( ie. 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, A, B, C, D, F). The same method to make numbers go from 1
digit to 2 digit we use for decimal numbers applies here! If we want to add
one to F we get 10. This is
were the confusion sets in. A(in hex) = 10(in decimal) and 10(in hex) = 16(in decimal).
One might often see hexadecimal numbers represented with a $ sign in front of
them. To
make this clearer have a look at the table below.
Table of comparing decimal and
hexadecimal number alphabet.
Decimal |
Hexa |
Decimal |
Hexa |
Decimal |
Hexa |
0 |
0 |
8 |
8 |
16 |
10 |
1 |
1 |
9 |
9 |
17 |
11 |
2 |
2 |
10 |
A |
18 |
12 |
3 |
3 |
11 |
B |
19 |
13 |
4 |
4 |
12 |
C |
20 |
14 |
5 |
5 |
13 |
D |
21 |
15 |
6 |
6 |
14 |
E |
22 |
16 |
7 |
7 |
15 |
F |
23 |
17 |