Learn
A1.2.1 | PRINCIPAL METHODS OF REPRESENTING DATA
01 | ONE VALUE, DIFFERENT WAYS TO WRITE IT
Imagine a score of twenty-six. We normally write it as 26 using decimal notation. The same value can be written as 11010 in binary or 1A in hexadecimal. The quantity has not changed; the notation used to represent it has.
A number base tells us which digits are available and what each position is worth. Decimal uses base 10, binary base 2 and hexadecimal base 16. Understanding place value lets you explain the conversions instead of memorising an isolated table.
This objective focuses on representing integers in binary and hexadecimal and converting between these and decimal. We begin with non-negative integers. The meaning of a signed bit pattern depends on the agreed representation, which must be specified separately.
The next lesson considers how binary encodings represent stored data more broadly. Here the goal is to understand the number itself: which digits are allowed, what their positions mean and how to recover the value.
02 | DECIMAL: PLACE VALUE YOU ALREADY USE
In decimal, the positions from right to left are worth 1, 10, 100, 1000 and so on. Each position is ten times the one immediately to its right. The digit tells you how many of that position’s value are included.
For example, 326 means three hundreds, two tens and six ones. Its value is 3 × 100 + 2 × 10 + 6 × 1. The same place-value principle works in other bases, but the multiplier between positions changes.
| Decimal position | Hundreds | Tens | Ones |
|---|---|---|---|
| Power of the base | 10² | 10¹ | 10⁰ |
| Position value | 100 | 10 | 1 |
| Digit in 326 | 3 | 2 | 6 |
| Contribution | 300 | 20 | 6 |
Any non-zero base raised to power zero gives 1, so the rightmost integer position is the ones position in each of these systems. Moving left multiplies the place value by the base.
03 | BINARY: TWO DIGITS, POWERS OF TWO
Binary uses only the digits 0 and 1. Its positions are worth powers of two: from the right, 1, 2, 4, 8, 16, 32, 64, 128 and so on. A 1 includes that place value; a 0 contributes nothing from that position.
A binary digit is a bit. Eight bits make a byte. Four bits are often called a nibble, a grouping that becomes particularly useful when converting to hexadecimal.
The binary pattern 00011010 has 1s in the 16, 8 and 2 positions, so it represents 16 + 8 + 2 = 26 as an unsigned value.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit in the example | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| Contribution | 0 | 0 | 0 | 16 | 8 | 0 | 2 | 0 |
Leading zeros can show a required width, such as an eight-bit field, without changing a non-negative integer’s value. 11010 and 00011010 therefore have the same unsigned value. A zero appended on the right changes the place values and normally changes the number.
04 | TRY THE EIGHT-BIT PLACE-VALUES
Click a bit to switch it between 0 and 1. Each button shows the bit and its place value. The totals update so you can connect the pattern to its decimal and hexadecimal representations.
Try making 26, then 128, then the largest unsigned value possible with eight bits. Predict which contributions are needed before clicking.
This activity interprets the pattern as unsigned. A different agreed representation can give the same bit pattern a different meaning.
05 | CONVERT BINARY TO DECIMAL
Write the binary digits under their powers-of-two place values. Multiply each digit by its place value and add the contributions. With only 0 and 1 available, you can simply add the headings with a 1 beneath them.
For 101101, start at the right with 1 and work left: 2, 4, 8, 16, 32. The selected headings are 32, 8, 4 and 1. Their sum is 45.
WORKED CONVERSION
101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1
= 32 + 8 + 4 + 1
= 45₁₀The small subscript indicates the base. 10₂ is two in decimal, while 10₁₀ is ten. Writing the base avoids ambiguity when several number systems appear in the same answer.
06 | CONVERT DECIMAL TO BINARY
One method is to choose powers of two from largest to smallest. For 45, choose 32, leaving 13. Skip 16, then choose 8, 4 and 1. Write a bit for every position, including the zero positions: 101101.
Another method is repeated division by two. Record each remainder, then divide the whole-number quotient again until it becomes zero. Read the remainders from the final row back to the first.
| Division | Whole-number quotient | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading those remainders bottom to top gives 101101. If eight bits are requested, pad on the left: 00101101. Do not reverse the whole-number quotients or read the remainders in their production order.
07 | HEXADECIMAL: SIXTEEN DIGIT VALUES
Hexadecimal uses sixteen digit values. The familiar symbols 0–9 represent zero to nine; A, B, C, D, E and F represent ten to fifteen. A is one hexadecimal digit, not two digits that should be separately processed as 1 and 0.
The positions from right to left are worth 1, 16, 256, 4096 and so on. Each step left multiplies the position value by sixteen.
| Hex digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Decimal value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Hex position | 16³ | 16² | 16¹ | 16⁰ |
|---|---|---|---|---|
| Place value | 4096 | 256 | 16 | 1 |
| Digit in 2AF | 0 | 2 | A | F |
| Contribution | 0 | 512 | 160 | 15 |
2AF₁₆ therefore means 2 × 256 + 10 × 16 + 15 = 687₁₀. The displayed leading zero shows the unused 4096 position; it does not change the value.
08 | CONVERT BETWEEN HEXADECIMAL AND DECIMAL
To convert hexadecimal to decimal, multiply each digit’s value by its place value and add the results. For 3C, C means twelve, so the value is 3 × 16 + 12 × 1 = 60.
To convert decimal to hexadecimal, repeated division works again, but divide by sixteen. Map remainders ten to fifteen to A–F, then read the remainders in reverse order.
| Division | Whole-number quotient | Remainder | Hex symbol |
|---|---|---|---|
| 687 ÷ 16 | 42 | 15 | F |
| 42 ÷ 16 | 2 | 10 | A |
| 2 ÷ 16 | 0 | 2 | 2 |
Reading the symbols bottom to top gives 2AF. A remainder of 10 must become the single symbol A; writing 21015 would not be a correct hexadecimal representation of this result.
Check by reversing the process: 2 × 256 + 10 × 16 + 15 = 687. A conversion method is stronger when you can verify its result in the other direction.
09 | FOUR BITS MATCH ONE HEX DIGIT
Four bits have 2⁴ = 16 possible patterns, from 0000 through 1111. Hexadecimal has exactly sixteen digit values, so each four-bit group maps directly to one hexadecimal digit.
For binary-to-hex conversion, group from the right into sets of four. Add leading zeros to the leftmost group if it is short. Convert each group separately, preserving the order of the groups.
HIGHER GROUP
1010↓
8 + 2 = 10
ALOWER GROUP
1101↓
8 + 4 + 1 = 13
D1010 1101₂ = AD₁₆. Check in decimal: 10 × 16 + 13 = 173.
For 101101₂, group as 10 | 1101, then pad the first group to 0010 | 1101. The result is 2D₁₆. Grouping from the left without preserving the right-aligned place values can give the wrong answer.
10 | HEXADECIMAL BACK TO BINARY
Replace each hexadecimal digit with its four-bit binary pattern. Keep the digits in the same order. Using four bits for every group preserves its position, including zeros inside the full number.
| Hex digit | Four-bit representation | Why the width matters |
|---|---|---|
| 3 | 0011 | Represents the higher group. |
| 0 | 0000 | Preserves an entire zero-valued middle group. |
| A | 1010 | Represents ten in the lower group. |
30A₁₆ becomes 0011 0000 1010₂. If a minimum-width answer is allowed, only the leading zeros of the complete number can be omitted: 1100001010₂. Removing the middle group of four zeros changes the value.
You do not need to convert the whole number to decimal first. The four-bit relationship gives a direct method in both directions.
11 | USE A CONVERSION AND WORKING CHECKER
Choose the input base and enter a non-negative integer. The checker displays the equivalent decimal, binary and hexadecimal forms and shows place-value or repeated-division working. It also groups binary into four-bit blocks.
For a manageable display, this activity accepts values from 0 to 65535: up to sixteen binary digits, four hexadecimal digits or five decimal digits within that range. This is an activity limit, not a claim that the IB syllabus or number systems stop at sixteen bits.
For binary and hexadecimal, you may include spaces between groups. Type only the digits, without prefixes such as 0b or 0x or a written subscript. Leading zeros are accepted within the stated width.
12 | SAME BITS, MORE COMPACT NOTATION
Hexadecimal is useful because a long binary pattern can be written with fewer symbols while keeping the direct four-bit relationship. Programmers may encounter hexadecimal when reading memory-related values, debugging output or colour codes.
The compact notation is for people and tools. Writing a bit pattern as hexadecimal does not, by itself, compress the underlying data or make the hardware process it faster. A byte written as 11111111₂ and FF₁₆ still describes the same eight-bit pattern.
For example, a common RGB colour notation #00FF80 specifies three components using two hex digits each. In that convention, red is 00 = 0, green FF = 255 and blue 80 = 128. The meaning comes from the agreed colour format, not from hexadecimal alone.
Likewise, whether a pattern is an integer, an address or part of some other encoding depends on context. The base tells you how to interpret the numeral, not every meaning an application assigns to its bits.
13 | WIDTH, RANGE AND VALID DIGITS
An unsigned field with n bits has 2ⁿ possible patterns, representing values from 0 to 2ⁿ − 1 when used as an ordinary non-negative integer. Eight bits therefore allow 0 to 255, not 1 to 256.
Each additional bit doubles the number of possible patterns. Two hexadecimal digits also describe 16² = 256 possible combinations, matching eight bits. Four hexadecimal digits match sixteen bits.
Check the allowed digits before converting. 10201 is not a valid binary numeral because binary has no digit 2. 3G is not valid hexadecimal because G is not among 0–9 and A–F.
A pattern such as 11111111 can mean 255 unsigned, but another representation can interpret it differently. Do not assume a signed interpretation unless its rule and width have been specified.
| Representation | Allowed digit values | Integer place values from the right |
|---|---|---|
| Decimal, base 10 | 0–9 | 1, 10, 100, 1000, … |
| Binary, base 2 | 0–1 | 1, 2, 4, 8, 16, … |
| Hexadecimal, base 16 | 0–9, A–F | 1, 16, 256, 4096, … |
14 | COMMON CONVERSION ERRORS
| Mistake | Correction |
|---|---|
| 11010₂ is read as the decimal numeral eleven thousand and ten. | Apply binary place values: 16 + 8 + 2 = 26. |
| A is treated as two separate hex digits 1 and 0. | A is one digit with value ten. |
| Repeated-division remainders are read top to bottom. | Read the last remainder first. |
| Binary groups are made from the left without padding. | Group from the right and pad only the leftmost short group. |
| A middle 0000 group is deleted during hex conversion. | Keep every four-bit group; internal zeros affect place value. |
| Eight bits have a maximum unsigned value of 256. | There are 256 patterns, with values 0 through 255. |
| Hexadecimal automatically compresses the stored byte. | It is compact notation for the same bit pattern. |
For describe the representation, identify the base, allowed digits and positional weights. For conversions, show the contributions, remainders or four-bit groups so someone can follow and check your method.
Try converting 93₁₀ to binary and hex, then reverse both conversions. Use the Questions tab to practise with different values rather than memorising one worked example.