A1.2.1 Describe the principal methods of representing data.
• The representation of integers in binary and hexadecimal
• Conversion of binary and hexadecimal integers to decimal, and vice versa
• Conversion of integers from binary to hexadecimal, and vice versa
📚 You can find additional information in the course companion pages 38 to 46
The big idea
Digital computers can only store and process patterns of on/off (1/0) states, so every kind of data—numbers, text, images, programs—must ultimately be encoded as sequences of binary digits (bits). Humans, however, are more comfortable working in base-10 (decimal) or in more compact bases such as base-16 (hexadecimal). To bridge the gap we need systematic, loss-free representations of integers in these different positional numeral systems and reliable algorithms for converting between them. Mastering these conversions is foundational: later topics (character encodings, floating-point, assembly instructions, networking protocols, cryptography) all assume you can fluently move between binary, hexadecimal and decimal.
1 Representing integers in different bases
| Base | Radix symbol | Place-value weights (right → left) | Typical grouping |
|---|---|---|---|
| Binary (base 2) | 0 or 1 | 2⁰, 2¹, 2², 2³, … | 8 bits = 1 byte |
| Decimal (base 10) | 0 … 9 | 10⁰, 10¹, 10², 10³, … | — |
| Hexadecimal (base 16) | 0 … 9, A … F | 16⁰, 16¹, 16², 16³, … | 1 hex digit ↔ 4 bits (1 nibble) |
The radix symbol is the set of digits available in a numeral system. It defines which symbols can appear in each position of a number written in that base. A radix is the number of unique digits, including the digit zero, used to represent numbers
Because 16 = 2⁴, each hex digit maps exactly to one 4-bit binary nibble, making hex a concise human-readable shorthand for long binary strings:
Binary : 0110 1010 1101 1111₂
Hex : 6 A D F₁₆
2 Converting binary ↔ decimal
Binary → Decimal
Use the place-value expansion:101101₂ = 1·2⁵ + 0·2⁴ + 1·2³ + 1·2² + 0·2¹ + 1·2⁰ = 45₁₀
Decimal → Binary
Repeatedly divide by 2, collecting remainders (least-significant bit first):
| Step | n ÷ 2 | Quotient | Remainder |
|---|---|---|---|
| 1 | 45 ÷ 2 | 22 | 1 |
| 2 | 22 ÷ 2 | 11 | 0 |
| 3 | 11 ÷ 2 | 5 | 1 |
| 4 | 5 ÷ 2 | 2 | 1 |
| 5 | 2 ÷ 2 | 1 | 0 |
| 6 | 1 ÷ 2 | 0 | 1 |
Read remainders bottom-to-top → 101101₂.
3 Converting hexadecimal ↔ decimal
Hex → Decimal
Expand in base 16 (remember A = 10, B = 11, …, F = 15):
2F₁₆ = 2·16¹ + 15·16⁰ = 32 + 15 = 47₁₀
Decimal → Hexadecimal
To convert a decimal (base-10) integer into hexadecimal (base-16), we express the number as a sum of powers of 16. The standard algorithm is repeated division by 16:
Algorithm (repeated division):
Divide the decimal number by 16.
Record the remainder (0–15).
If the remainder is 10–15, map it to A–F.
Update the number by taking the quotient of the division.
Repeat until the quotient becomes 0.
The hexadecimal result is the sequence of remainders read bottom-to-top (last remainder is the most significant digit).
Worked Example: Convert 202₁₀ to Hex
202 ÷ 16 = 12 remainder 10
10 maps to A
12 ÷ 16 = 0 remainder 12
12 maps to C
Remainders bottom → top: CA₁₆
So:
202₁₀ = C A₁₆
4 Converting binary ↔ hexadecimal (fastest)
Group binary into nibbles from the right and translate directly:
Binary : 1101 0110 ₂
Hex : D 6₁₆
Reverse mapping is equally direct by expanding each hex digit into its 4-bit pattern.
5 Range and storage considerations
For an unsigned n-bit word the representable range is 0 … 2ⁿ – 1.
Example: 16-bit unsigned integer → 0 … 65 535₁₀ → 0000₁₆ … FFFF₁₆.
(For signed integers, two’s-complement encoding is used; that topic appears later in the syllabus.)