Converting RGB Triplets to Hexadecimal Numbers
The conversion is a fairly simple process and there are a number of ways
to do it. Here's one that works with a little division and the table below.
Remember that the highest number that you will need to deal with is 255.
You will need 2 digits to represent each number.
Method A - for people who like division
Method B - for those who prefer subtraction
Method C - for the rest of us who like to use
a calculator (at least look at Methods A and B since they'll give you an
understanding of how the conversion works
Method A
For a number less than 16, the first digit will be 0, and for the second
digit, just look at the chart and choose the number that is below the decimal
number you are converting.
For example 13 is equal to 0D.
Numbers 16 or larger will require some division.
Let's say that you want to convert 118 to a hexidecimal.
118 divided by 16 = 7 r 6 (7 remainder 6)
First look under the 7 to get the first digit
Then look under the 6 to get the second digit
The answer is 76
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
Now try another one:
219 Divided by 16 = 13 remainder 11
The 13 becomes a D
the 11 is an B
The answer is DB.
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
You've probably noticed that you don't really need the chart when the
number is less than 9.
top
Method B
Here's a 2 chart method that uses subtraction rather than division.
Again, we'll try 219.
Look in the top chart for the number that is just below yours.
In this case it is 208 which is D
| 0 |
16 |
32 |
48 |
64 |
80 |
96 |
112 |
128 |
144 |
160 |
176 |
192 |
208 |
224 |
240 |
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
Now subtract 208 from your number 219-208= 11
Check chart 2 (which is the same as the chart that we used in the division
method) and find that the second digit is B
So 219 is equal to DB in hexadecimal.
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
| 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
therefore, 219 is written as DB in hexidecimal.
top
Method C
Use the calculator that is a part of Windows 98
-
Open the calculator that came with Windows 98.
-
View-->Scientific
-
Select the Dec radio button
-
Type in the decimal value for Red
-
Select the Hex radio button
-
Write down the results
-
Select the Dec radio button
-
Type in the decimal value for Green
-
Select the Hex radio button
-
Write down the results
-
Select the Dec radio button
-
Type in the decimal value for Blue
-
Select the Hex radio button
-
Write down the results
top
|