HEX conversion Guide:
How the hexadecimal system works and how to understand HEX numbers:
- Hexadecimal means it takes 16 units for a number to have two digits.
- Decimal (conventional system) means it takes 10 units for a number to have two digits.
A "10" in decimal system means ten, and "10" in hexadecimal system means sixteen.
The "1" in 10 means one decimal place up (ten or sixteen units reached). A simple formula to know it:
- For now, we'll use numbers with two algarisms only. Take the first algarism on the left and multiply it by "what it takes to have two digits" in the system you're using (ten or sixteen).
- Ex. 1: Take the number 10: 1(the first algarism) multiplied by 10(what it takes to have two digits) = 10. In decimal system 10 means ten.
- Now: 1 x 16 = 16. In hexadecimal system 10 means sixteen. "10" represents one 16 plus 0.
- Ex. 2: Take 20: Right into HEX. 2 x 16 = 32.
- Ex. 3: Take 70: 7 x 16 = 112.
- Ex. 4: Take 90: 9 x 16 = 144.
The last algarism, that represents the units, has just to be added to the sum. More examples later.
Now it's time for you to look at this table:
| Decimal: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| Hexadecimal: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 | 11 | 12 | 13 | 14 |
I hope you could see there that in hexadecimal the letters A-F work as substitute numbers. Since the number will go up one place only when it reaches 16, you must have new algarisms to represent numbers from 10 to 15, since these use up two algarisms.
Instead of creating new numbers, the letters have been adopted.
(I use the term "decimal place" when refering to HEX numbers, but actually the correct term is "hexadecimal place")
- Now to complete our (no - your) knowledge, the other examples including units:
- Ex. 5: Take 47: 4 x 16 = 64; 64 + 7 = 71. In decimal, 4 x 10 = 40; 40 + 7 = 47.
- Ex. 6: Take 11: 1 x 16 = 16; 16 + 1 = 17.
- Ex. 7: Take 98: 9 x 16 = 144; 144 + 8 = 152.
- We're going to use the new HEX algarisms:
- Ex. 8: Take 1C: 1 x 16 = 16; 16 + 12(the value C represents) = 28.
- Ex. 9: Take 1F: 1 x 16 = 16; 16 + 15 = 31.
- Ex. 10: Take 5A: 5 x 16 = 80; 80 + 10 = 90.
- Ex. 11: Take A0: 10 x 16 = 160.
- Ex. 12: Take BD: 11 x 16 = 172; 172 + 13 = 185.
- Ex. 13: Take E3: 14 x 16 = 224; 224 + 3 = 227.
- Ex. 14: Take EE: 14 x 16 = 224; 224 + 14 = 238.
- Ex. 15: Take FF: 15 x 16 = 240; 240 + 15 = 255.
Well, I hope you know how to do it. Oh, I won't stay on hope, so here's some exercises for you:
(type the results in the box, in the middle of each question, then click "Ok"; it's "ok" as well if you to use a calculator - but NOT the color converter!)
Want more? I just keep adding them, it's my revenge from school time - pass it onto others...well, back to it. It's time to do the reverse: put a decimal number in HEX!
You'll only need to have completed primary school and know the formula:
- Decimal to HEX: there are two ways - 1) doing it on paper or in your mind; 2) using a calculator machine.
- 1) Divide the number by 16, set aside the rest of the division. Use the table for numeric equivalents (A=10...). You now have the decimal place. The rest of the division becomes the units. You don't add the results, place the individual numbers you'll find as HEX algarisms side-by-side.
Ex. 1: You have 81: 81 divided by 16 (81 / 16) = 5. The rest of the division is 1. The result is "51" in HEX.
Ex. 2: You have 200: 200 / 16 = 12(C). The rest is 8. The result is "C8" in HEX.
- 2) Divide the number by 16. What you obtain before the "marker" (comma or period) is the number for the decimal place of your final number. Convert it into a HEX algarism if necessary. Since you won't have the rest of the division in a calculator, take that number after the "marker" and multiply it by 16. This becomes the units.
Ex. 1: You have 200 again: 200/16 = 12,5 (you have now C from the 12). 0,5 x 16 = 8. The result is "C8" in HEX.
Ex. 2: You have 73 oranges. A greek guy asks you to write down how many oranges you have in hexadecimal. Assuming you won't lie to him for no reason: 73/16 = 4,5625. Now 0,5625 x 16 = 9. The result: "49" in HEX.
Ex. 3: You want to know what your nerd friend (we all have one) wrote on the back of his history test - 227 - has to do with anything at all. Trying to figure it out, you try one possibility - yes - : convert it to a HEX number. 227/16 = 14,1875. Do 0,1875 x 16 = 3. "E3". Had to be that freak to note that in reversed HEX on the back of his test!
- Also check the table below for a quick reference on the whole number equivalents of the divided rests you'll obtain in case 2).
And it's time for some more exercises (nooooo)! Just three, really.
Last part: numbers higher than 255 / more than 3 HEX algarisms.
- HEX to decimal:
- You get each algarism of the HEX number and multiply them individualy by 16its decimal place. The decimal place is the number of the algarism, counting from 0 right-to-left (it's 1 for the "1" on "10", 2 for the "1" on "100", etc.)
- Example: You have 123 HEX apples :-) Last decimal place (on the left): 1 x 162 = 256 (162 is 16 twice - 16 x 16). Middle decimal place: 2 x 161 = 32 (161 is the same as just 16). Add them all (units included): 256 + 32 + 3 = 291.
- Last example: Take 5280A0. Let's go faster on this one:
- 5 x 165 = 5.242.880
- 2 x 164 = 131.072
- 8 x 163 = 32.768
- 0 x 162 = 0
- 10(A) x 16 = 160
- Add them all: 5.242.880 + 131.072 + 32.768 + 0 + 160 + 0(the units) = 5.406.880 in decimal.
- Decimal to HEX:
- If the number you have is equal to or greater than 16, you must divide it. Should the result of the first division by 16 be still equal to or greater than 16, you go on dividing. The rest of the first division becomes the units in the HEX number (last digit on the right). The rest of each successive division is placed on its left. The result of the last division you'll have to make becomes the last algarism on the left of the HEX number. Once again, numbers from 10 to 15 have to be replaced by HEX algarisms.
- Example: Put 900 into HEX. 900/16 = 56. The rest is 4. Once again: 56/16 = 3, and the rest 8. The final number is "384".
- Another example: Put 256 into HEX. 256/16 = 16. There's no rest. Again, 16/16 = 1. The final outcome is "100".
- Last enormous example: 6983400. Going fast:
- 6983400/16 = 436462, rest 8.
- 436462/16 = 27278, rest 14 (E).
- 27278/16 = 1704, rest 14 (E).
- 1704/16 = 106, rest 8.
- 106/16 = 6, rest 10 (A).
- Putting them all together, last one first: "6A8EE8" (including the result of the last division).
For your leisure, I offer you the table containing "quick conversion" numbers for a calculator to convert decimal to HEX:
(these represent the numbers after the "," or "." in a division; numbers in ascending order)
| Divided rest: | 0,0625 | 0,125 | 0,1875 | 0,25 | 0,3125 | 0,375 | 0,4375 | 0,5 | 0,5625 | 0,625 | 0,6875 | 0,75 | 0,8125 | 0,875 | 0,9375 |
| Undivided rest: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A(10) | B(11) | C(12) | D(13) | E(14) | F(15) |
Formula Reference
(in any operation, remember to convert HEX numbers A-F to and from decimal numbers 10-15 as needed)
- HEX to decimal:
Multiply each algarism individualy by 16decimal place and add the individual results to obtain the final one.
place is the number of the place where the algarism is at, starting with 0 from right to left.
Note: 160 = 1, and 161 = 16.
- Decimal to HEX:
As long as the number is equal to or greater than 16, divide it by 16. The rest of each division is placed as a single HEX algarism on the left of the previous, until the result of the last division is placed also on the left.
HEX conversion guide written by
- 2004
|