Convert between positive denary and positive hexadecimal
Data Representation: Converting between Positive Denary and Positive Hexadecimal
What is Denary?
Denary (decimal) is the number system we use every day. It has 10 digits: 0–9. It is base‑10, meaning each place value is a power of 10.
What is Hexadecimal?
Hexadecimal is base‑16. It uses 16 symbols: 0–9 and A–F (where A=10, B=11, …, F=15). Think of it like a phone keypad where after 9 comes A, B, C, D, E, F.
Why Convert?
Computers store data in binary, but programmers often use hex because it is shorter and easier to read. Converting between denary and hex helps you understand how numbers are represented inside the computer.
Converting Denary ➜ Hexadecimal
- Divide the denary number by 16.
- Write down the remainder (0–15). If the remainder is 10–15, write the corresponding letter A–F.
- Replace the number with the quotient and repeat until the quotient is 0.
- Read the remainders in reverse order to get the hex number.
Example: Convert 255 to hex.
- 255 ÷ 16 = 15 remainder 15 → F
- 15 ÷ 16 = 0 remainder 15 → F
Read backwards: FF.
Converting Hexadecimal ➜ Denary
- Write the hex digits from left to right.
- Assign each digit a power of 16, starting with 0 on the right.
- Multiply each digit by 16position and sum the results.
Example: Convert 0x1A3 to decimal.
$1 \times 16^2 + 10 \times 16^1 + 3 \times 16^0 = 256 + 160 + 3 = 419$.
Hex Digit Reference Table
| Hex | Denary |
|---|---|
| 0 | 0 |
| 1 | 1 |
RevisionLog in to practice.
1 views
0 suggestions
|