Converting decimal to hexadecimal
You can calculate hex values in the 0 to 255 range by dividing a number by 16 to get the first digit, then using the remainder for the second digit. For example, dividing the decimal number 203 by 16 yields 12 with a remainder of 11. The hexadecimal value of 12 is C; the hex value of 11 is B. Therefore, the hexadecimal equivalent of 203 is CB.
Fortunately, there are simpler methods for converting numbers to hexadecimal:
Use a hexadecimal calculator. Windows users can find a hexadecimal calculator in the “Scientific” view of the Windows standard calculator. Mac users with OS X 10.4 (Tiger) can download the free Hex Calculator Widget at http://www.apple.com/downloads/dashboard/calculate_convert/hexcalculatorwidget.html.
Use Table D-1, which translates decimal values from 0 to 255.
Table D-1. Decimal to hexadecimal equivalents
dec = hex |
dec = hex |
dec = hex |
dec = hex |
dec = hex |
dec = hex |
---|---|---|---|---|---|
0 = 00 |
43 = 2B |
86 = 56 |
129 = 81 |
172 = AC |
215 = D7 |
1 = 01 |
44 = 2C |
87 = 57 |
130 = 82 |
173 = AD |
216 = D8 |
2 = 02 |
45 = 2D |
88 = 58 |
131 = 83 |
174 = AE |
217 = D9 |
3 = 03 |
46 = 2E |
89 = 59 |
132 = 84 |
175 = AF |
218 = DA |
4 = 04 |
47 = 2F |
90 = 5A |
133 = 85 |
176 = B0 |
219 = DB |
5 = 05 |
48 = 30 |
91 = 5B |
134 = 86 |
177 = B1 |
220 = DC |
6 = 06 |
49 = 31 |
92 = 5C |
135 = 87 |
178 = B2 |
221 = DD |
7 = 07 |
50 = 32 |
93 = 5D |
136 = 88 |
179 = B3 |
222 = DE |
8 = 08 |
51 = 33 |
94 = 5E |
137 = 89 |
180 = B4 |
223 = DF |
9 = 09 |
52 = 34 |
95 = 5F |
138 = 8A |
181 = B5 |
224 = E0 |
10 = 0A |
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.