We use the same division technique for octal and binary to convert decimal to hexadecimal, except we divide using 16. We will use decimal 112 again.
Division by 16 | Remainder | Hex |
---|---|---|
112 / 16 = 7 | 0 | 0 |
7 / 16 = 0 | 7 | 7 |
We can read the table hex values from the bottom up to find our final hex. Hence, we have decimal 112 as 0x70. Note that hexadecimal is more compact at storing large numerical values than binary, octal, and decimal.
Let’s try again with decimal 4156 (remember to scroll):
Division by 16 | Remainder | Hex |
---|---|---|
4156 / 16 = 259 | 12 | C |
259 / 16 = 16 | 3 | 3 |
16 / 16 = 1 | 0 | 0 |
1 / 16 = 0 | 1 | 1 |
Reverse our final column by reading upwards, and we get 0x103C in the standard hex notation for most computer languages.
Instructions
Convert decimal 1543 to its hexadecimal equivalent.
Assign your answer to checkpoint_1
in the code editor. Be sure to include any necessary prefix.
Convert decimal 2748 to its hexadecimal equivalent.
Assign your answer to checkpoint_2
in the code editor. Be sure to include any necessary prefix.