Loading...
A value can be written in different bases without changing its meaning. Use place weights and explicit widths to convert positive integers accurately and check the result independently.
What you'll be able to do
Denary uses ten digits, 0 through 9. Binary uses two, 0 and 1, while hexadecimal uses sixteen symbols, 0 through 9 and A through F. A hexadecimal A denotes the value ten, not an additional place or a multiplication sign. State the base because the same written digits can describe different values.
For example, 10 in binary is two in denary, while 10 in hexadecimal is sixteen. A computer’s physical representation uses bit patterns; hexadecimal makes those patterns shorter for people to inspect. Fixed width is another property: adding leading zeroes can preserve an unsigned value while ensuring that an address or register display has its required number of positions.
In base b, successive integer positions have weights 1,b,b² and so on. Binary uses digits 0 and 1; hexadecimal uses 0–9 and A–F for values 10–15. A subscript or another explicit label distinguishes a base-16 representation from a decimal number.
Convert to decimal by summing digit×place-value products. Convert a non-negative integer to another base by repeated division, recording remainders and reading them in reverse order. Verify by expanding the result back into decimal rather than trusting a remembered visual pattern.
One hexadecimal digit represents exactly four binary bits because 16=2⁴. Group binary digits into fours from the binary point or integer right-hand end, adding harmless leading zeroes when needed. A hexadecimal string is therefore a compact readable representation of the same bit pattern.
The grouping does not perform encryption or change the stored information. Leading zeroes can matter when a fixed-width identifier or bit pattern is required, even though they do not change an unsigned integer’s value. Keep value, width and representation distinct throughout the conversion.
| Representation | Expansion | Decimal value |
|---|---|---|
| 101101₂ | 32+8+4+1 | 45 |
| 2D₁₆ | 2×16+13 | 45 |
| 0010 1101₂ | 2 → 0010; D → 1101 | 45 |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.