Base ten: In base ten there are ten digits: 0,1,2,3,4,5,6,7,8,9 and place values go up buy factors of ten. The right most place is the one's place. Now multiply that by ten. The next place is the ten's place. And multiply that by ten. The third place is the hundred's place, and the next place is the thousand's place.
Base sixteen: (also called Hex).
In base sixteen there are sixteen digits:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F, where digits A-F corresond
to the decimal values below:
Hex digit decimal value A 10 B 11 C 12 D 13 E 14 F 15In Hex the place values go up by factors of sixteen. The right most place is still the one's place. The next place sixteen times that. It is the sixteen's place. The next place is sixteen times that. It is the two-hundred-fifty-six's place.
Conversion of Hex color to decimal.
Example: convert the Hex color #F5AC9D
to rgb format.
First we split the Hex color into 3 parts. The left most two digits,
F5,
make up the red component. The middle two digits,
AC,
make up the green component. Finally, the
last two digits, 9D,
make up the blue component.
red component conversion to decimal:
Hex F5. 5 is in the one's place and F is in the sixteen's place.
Now Hex digit F stands for 15 (see table above).
Since it is in the sixteen's place
we have 15 16's, and then 5 1's.
Hex f5 = 15*16 + 5*1 = 245 decimal.
green component conversion to decimal:
Hex AC. C is in the one's place, and A is the sixteen's place.
According to the table, C has a value of 12 and A has a value of 10.
Hex AC = 10*16 + 12*1 = 172
blue component conversion to decimal:
Hex 9D. D is in the one's place and 9 is in the sixteen's place.
According to the table the value of D is 13.
Hex 9D = 9*16 + 13*1 = 157 decimal
So in decimal format the color is rgb(245,172,157)
Conversion of decimal color to Hex.
Example: convert the decimal color
rgb(91,195,66)
to Hex.
Red Component.
decimal 91: Divide 91 by 16:
91//16 = 5
91%16 = 11
So there are 5 16's in 91 with 11 1's left over. We convert value 11
to Hex digit B. So
decimal 91 = 5B Hex.
Green Component.
decimal 196: Divide 195 by 16.
195//16 = 12
195%16 = 3
So there are 12 16's in 195 with 3 1's left over. We convert value 12
to Hex digit C. So
decimal 195 = C3 Hex.
Blue Component.
decimal 66: Divide 66 by 16.
66//16 = 4
66%16 = 2
So there are 4 16's in 66 with 2 1's left over. So
decimal 66 = 42 Hex.
Finally we combine the three components:
rgb(91,195,66) = #5BC342