Quarry School

Computer Science Foundations / Information in bits

Information in bits

Subject: Computing

All 5 lessons, in order.

The unit at a glance

  1. Give one bit a meaning

    Two friends agree on a porch light ahead of time.

  2. Read binary place values

    Picture a kitchen scale and four weights marked 8 grams, 4 grams, 2 grams and 1 gram.

  3. Find what fits in three bits

    Imagine a fair booth that prints 000 on its first ticket.

  4. Encode a character as bytes

    Imagine a coat check.

  5. Decode a tiny bitmap

    Imagine leaving a note for a friend about two squares side by side on a calendar.

Rules (5)
  • Give one bit a meaning

    A bit has two possible states, so each mark on paper is either 0 or 1. A mark has no meaning until the sender and the receiver share a key, and that key must give the two marks two different meanings. Decode one mark at a time, from left to right, and write one word per mark. Keep the marks and change the key, and you get a different message.

  • Read binary place values

    This rule models one convention: a four-bit unsigned pattern with exactly four bits, columns worth 8, 4, 2 and 1 from left to right, and no sign. Other conventions read the leftmost bit as a plus or minus sign, so the answers here hold only when the pattern is stated to be unsigned.

    To decode, the initial state is a total of 0 with your pencil at the 8 column. Move left to right, one column at a time. If the column holds 1, add its value to the total; if it holds 0, add nothing. Stop after the 1 column, and the total is the number.

    To encode, the initial state is a remaining amount equal to the number, with four empty boxes under the headers 8 4 2 1. Move left to right, starting at the 8 column. If the column's value is no more than the remaining amount, write 1 and subtract the value; otherwise write 0. Stop after the 1 column. If the remaining amount is 0, the four marks are the pattern; if it is not 0, the number does not fit in four bits.

  • Find what fits in three bits

    Start with one empty row and double the count for each bit you add. Two choices for each of three positions make eight patterns. The unsigned values run from zero to one less than the pattern count. With three bits they run from 0 through 7.

  • Encode a character as bytes

    Capital A has code point U+0041. Its UTF-8 byte is 41. Lowercase é has code point U+00E9. It uses two UTF-8 bytes, C3 first and A9 second.

    A base letter followed by a separate combining accent can use two code points, one for the letter and one for the accent. Together they form a combining sequence. Use the single code point U+00E9 for each é in this lesson's inputs.

  • Decode a tiny bitmap

    The paper format is the set of rules that tells you how to read the bits. It gives you the width, height, colour key and reading order. Both dimensions are whole numbers of at least one. Multiply the width by the height to count the squares. You need exactly that many bits, including every 0.

    For the two grids shown here, the key is 1 for ink and 0 for white paper. Start with an all-white grid and the first bit. Work across each row from left to right, starting with the top row. Stop when you use the last bit in the bottom-right square.

Recipes (5)
  • Give one bit a meaning
    1. Agree on the key with your partner and write it down before anyone sets a tile. In this lesson, Key A says 0 means waiting and 1 means ready.
    2. To reverse a key, swap its two meanings. Key B, the reversed lift key, says 0 means ready and 1 means waiting. Reversing the key never changes the order of the marks.
    3. Check the marks. Only 0 and 1 are allowed. If a mark is anything else, or a tile shows no clear face, write "not in the key" and stop instead of guessing.
    4. Start with an empty message. This is the starting point of your trace.
    5. Read the marks from left to right, one mark at a time.
    6. Look up each mark in the key and write its word at the end of the message. In this lesson a mark means the same thing wherever it sits in the row.
    7. Stop when no marks are left. Count the words: there should be one word for each mark.
    8. To encode, work the other way: look up each word in the key and write its mark.
    9. To check, encode your decoded message with the same key. If you get the original marks back, your decoding holds. This check is called a round trip.
  • Read binary place values
    1. Write the headers 8 4 2 1 across your paper and draw a box under each.
    2. To decode, copy the pattern into the boxes, one digit per box. Check that there are four digits and that each is 0 or 1.
    3. Set the total to 0. Working left to right, add the header of every box that holds 1 and skip every box that holds 0.
    4. Stop after the 1 column. The total is your number.
    5. To encode, write the number as the remaining amount. Working left to right, ask whether the header is no more than the remaining amount.
    6. If it is, write 1 in that box and subtract the header from the remaining amount. If it is not, write 0.
    7. Stop after the 1 column. If the remaining amount is 0, read the four boxes as your pattern and keep any leading zeros. If it is not 0, the number does not fit in four bits.
    8. Check by running the rule the other way: decode the pattern you wrote, or encode the number you found, and compare with where you started.
  • Find what fits in three bits
    1. Write down the convention, the rule for using the codes. Give each ticket a different three-bit pattern and make every pattern available.
    2. Begin with no digits and fill the slots from left to right. Follow 0 before 1 at each split. Record the row once it has three digits, then go back to the last split with a branch left to follow. Finish when you have followed every branch.
    3. Count the finished rows, including 000. Find the largest unsigned value by adding the place values in the all-ones row.
  • Encode a character as bytes
    1. Use UTF-8. Start with an empty row and a byte count of zero. Write one box per byte and two hex digits per box.
    2. Read the input from left to right. For each letter, find its code point in The rule. Add that code point's bytes to the right of the row in the order shown.
    3. Stop once you have written the bytes for the last letter. Read the finished row left to right and count the boxes.
  • Decode a tiny bitmap
    1. Draw the given number of columns and rows. Leave all squares white. Count the squares and the bits. If the counts differ, stop before shading and report the two counts.
    2. Start at the top-left square with the first bit. Use the key to decide whether to shade the square or leave it white.
    3. Use the next bit in the next square to the right. At the end of a row, move to the leftmost square of the next row down if there is one. Stop after you use the last bit in the bottom-right square.
    4. Read the drawing back from the top left in the same order. Use the key to write one bit per square and join the rows into one line with no spaces.
Traps (5)
  • Give one bit a meaning

    The usual mistake is to treat the mark as if it were the meaning: "1 is ready, full stop." The tile shows only a face. Ready comes from Key A, and under Key B the same face means waiting. A computer keeps physical states, not the digits 0 and 1, so the digit names a state and the key turns that state into a meaning.

    The second mistake is to reverse the marks instead of the key. The row 1, 0, 1 reads the same backwards, so flipping its order gives 1, 0, 1 again and repeats Key A's message without anyone noticing. Try 1, 1, 0 under Key A instead: it decodes as ready, ready, waiting.

    Reversing the order of 1, 1, 0 gives 0, 1, 1, which Key A decodes as waiting, ready, ready. Reversing the key gives waiting, waiting, ready. These are three different answers, and only the last one answers "reverse the key".

    A key that gives both marks the same meaning, such as 0 means ready and 1 means ready, also fails. Every message decodes as ready, and waiting can never be sent.

  • Read binary place values

    If you read 1010 as one thousand and ten, you have used decimal columns, which step by ten: 1000, 100, 10 and 1. The same four marks then name a much larger number. Binary columns step by two, so 1010 in binary is 8 + 2 = 10.

    Three habits guard against this. Write "in binary" next to the pattern, write the headers 8 4 2 1 above the digits before you read, and check that every digit is 0 or 1. A digit from 2 to 9 means the marks are not a binary pattern at all.

  • Find what fits in three bits

    If you counted seven codes, check where you started. The pattern 000 reads as zero and is one of the eight patterns. If the booth sets 000 aside to mean “no ticket,” it still appears in the list. The booth has seven codes to hand out.

  • Encode a character as bytes

    A character count alone leaves the UTF-8 byte count open. AA and Aé each have two letters here. AA takes two bytes, and Aé takes three. Work out how many bytes each code point adds before counting the total.

  • Decode a tiny bitmap

    Use the width to decide where to end each row. Grid A needs three bits across each of its two rows. If you use the height of two as the row length and lay out all six bits, the third bit starts a new row and you get Grid B. Check the key as well. If you swap what 0 and 1 mean, every ink square becomes white and every white square becomes ink.

Lesson 1 of 5

Give one bit a meaning

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Two friends agree on a porch light ahead of time. Light on means "come over", and light off means "not tonight". The light can look only two ways, and the friends decided what each look means. This lesson builds the same idea with a paper tile.

A state is the way a thing is at one moment. Our tile is a small square of paper with 0 written on one face and 1 on the other, and the face that points up is its state. A mark is the 0 or 1 you write on paper to record a state. A bit is short for "binary digit": a digit that can take only two values, and binary names a system with only two digits.

A key is the agreed rule that says what each mark means. Another word for a key is a convention. To encode is to turn a meaning into a mark with the key, and to decode is to turn a mark back into a meaning. A message is the list of meanings you get, one per mark, and a trace is your written record of each step.

For a short reading, open section 5.1 of the Computer Science Field Guide, "What's the big picture?". Read the Jargon Buster box on bits and the paragraph on writing a computer's states on paper as 0 and 1. Remember three things: a tile shows one of two states, the key gives that state a meaning, and both people need the same key before any message is sent. Look the key up each time you decode, even when you think you know it.

2 Picture it

01Key A0 = waiting1 = readyKey B0 = ready1 = waiting101

The tiles read 1, 0, 1. When 1 means ready, they read ready, waiting, ready. Swap the key and they read waiting, ready, waiting.

One row of marks under two keys

3 Why

A computer does not hold the digits 0 and 1 themselves. It holds physical states, such as a low or a high voltage in memory, or a tiny spot on a magnetic disk magnetised north or south, and people write those states down as 0 and 1. Anything that can be in two states can hold a bit, and which digit is written for which state is a choice people make.

Because people make that choice, the meaning lives in the key and not in the tile. Computers also use a rule to turn a stored value into something a reader understands. The Field Guide's example is a date: the computer stores a number, and program code turns that number into a date the reader sees.

Decoding is a lookup. The tiles fix which state comes first, second and third, and the key turns each state into a word. A key has only two meanings to hand out, so reversing it gives the other word at every position while the tiles stay exactly as they were.

4 The rule

A bit has two possible states, so each mark on paper is either 0 or 1.

A mark has no meaning until the sender and the receiver share a key, and that key must give the two marks two different meanings. Decode one mark at a time, from left to right, and write one word per mark. Keep the marks and change the key, and you get a different message.

5 How

  1. Agree on the key with your partner and write it down before anyone sets a tile. In this lesson, Key A says 0 means waiting and 1 means ready.
  2. To reverse a key, swap its two meanings. Key B, the reversed lift key, says 0 means ready and 1 means waiting. Reversing the key never changes the order of the marks.
  3. Check the marks. Only 0 and 1 are allowed. If a mark is anything else, or a tile shows no clear face, write "not in the key" and stop instead of guessing.
  4. Start with an empty message. This is the starting point of your trace.
  5. Read the marks from left to right, one mark at a time.
  6. Look up each mark in the key and write its word at the end of the message. In this lesson a mark means the same thing wherever it sits in the row.
  7. Stop when no marks are left. Count the words: there should be one word for each mark.
  8. To encode, work the other way: look up each word in the key and write its mark.
  9. To check, encode your decoded message with the same key. If you get the original marks back, your decoding holds. This check is called a round trip.

6 Trace

Read 1, 0, 1 with both lift keys
PositionBit0 means waiting0 means readyExplanation
11readywaitingLook up 1 in each key.
20waitingreadyLook up 0 without changing the tile.
31readywaitingRead the last tile with the same key as the earlier ones.

7 The trap

The usual mistake is to treat the mark as if it were the meaning: "1 is ready, full stop." The tile shows only a face. Ready comes from Key A, and under Key B the same face means waiting. A computer keeps physical states, not the digits 0 and 1, so the digit names a state and the key turns that state into a meaning.

The second mistake is to reverse the marks instead of the key. The row 1, 0, 1 reads the same backwards, so flipping its order gives 1, 0, 1 again and repeats Key A's message without anyone noticing. Try 1, 1, 0 under Key A instead: it decodes as ready, ready, waiting.

Reversing the order of 1, 1, 0 gives 0, 1, 1, which Key A decodes as waiting, ready, ready. Reversing the key gives waiting, waiting, ready. These are three different answers, and only the last one answers "reverse the key".

A key that gives both marks the same meaning, such as 0 means ready and 1 means ready, also fails. Every message decodes as ready, and waiting can never be sent.

Quick checks

Quick check 1 of 2

With Key A, where 0 means waiting and 1 means ready, encode the message waiting, waiting, ready.

Show the steps and the answer
Answer

0, 0, 1

Why: Look up each word in Key A from left to right: waiting gives 0, waiting gives 0, ready gives 1. To check, decode 0, 0, 1 with Key A and you get waiting, waiting, ready back.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: Data Representation, 5.1 What's the big picture?

Quick check 2 of 2

A shop hangs a tile in its window each morning. Its key says 1 means open and 0 means closed. The marks for three mornings, first morning on the left, are 0, 1, 1. Decode them. Then decode the same marks with the key reversed.

Show the steps and the answer
Answer

With the key: closed, open, open. With the key reversed: open, closed, closed.

Why: The marks keep the same order. Only the meaning of each face swaps, so every word changes to the other word. Reading the marks backwards with the original key gives open, open, closed, which answers a different question.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: Data Representation, 5.1 What's the big picture?

Sources

  1. Computer Science Field Guide: Data Representation, 5.1 What's the big picture?. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.
  2. Computer Science Field Guide: Data Representation, 5.3 Numbers. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.

Lesson 2 of 5

Read binary place values

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Picture a kitchen scale and four weights marked 8 grams, 4 grams, 2 grams and 1 gram. Each weight is either on the scale or off it, and no weight goes on twice. Write 1 under each weight that is on and 0 under each weight that is off. The four marks then record the total on the scale.

That row of marks is a binary number. Binary writes numbers with only two digits, 0 and 1, and each of those marks is one bit. The numbers you use every day are decimal, also called base 10, which uses the ten digits 0 to 9.

In both systems, what a digit is worth depends on its place, the position it sits in. Call each position a column and call what it is worth its place value. A four-bit pattern is a row of exactly four bits, and its place values from left to right are 8, 4, 2 and 1. Each column is worth twice the column on its right.

A short reading: take 1010 in binary. The 8 column holds 1, the 4 column holds 0, the 2 column holds 1 and the 1 column holds 0. Add the columns that hold a 1: 8 + 2 = 10.

Four more words finish the toolkit. To decode is to turn a pattern into a number, and to encode is to turn a number into a pattern. Unsigned means the pattern carries no plus or minus sign, so it names a whole number from 0 up. A leading zero is a 0 at the left end, and a four-bit pattern keeps it, so 6 is written 0110, not 110.

Remember one line: the column headers 8 4 2 1. When you meet a pattern, write those headers above it and add, rather than memorising patterns. Four bits reach at most 1111, which is 15, so any larger number needs more bits.

2 Picture it

814021108 + 2 = 10

From the left, the places are worth 8, 4, 2 and 1. In 1010, the first and third places contribute 8 and 2.

Four places have four different values

3 Why

Binary uses the same place idea as decimal with a different step. Decimal columns step by ten, so they are worth 1, 10, 100 and 1000 from the right. Binary columns step by two, so they are worth 1, 2, 4 and 8 from the right. A 1 adds its column's value to the total, and a 0 adds nothing.

Each binary column is also worth more than all the columns to its right put together. The sum 4 + 2 + 1 is 7, less than 8; 2 + 1 is 3, less than 4; and 1 is less than 2. So when you encode from the left, any column that fits must be used, because the smaller columns together can never make up for skipping it. That is why each whole number from 0 to 15 has exactly one four-bit pattern.

4 The rule

This rule models one convention: a four-bit unsigned pattern with exactly four bits, columns worth 8, 4, 2 and 1 from left to right, and no sign.

Other conventions read the leftmost bit as a plus or minus sign, so the answers here hold only when the pattern is stated to be unsigned.

To decode, the initial state is a total of 0 with your pencil at the 8 column. Move left to right, one column at a time. If the column holds 1, add its value to the total; if it holds 0, add nothing. Stop after the 1 column, and the total is the number.

To encode, the initial state is a remaining amount equal to the number, with four empty boxes under the headers 8 4 2 1. Move left to right, starting at the 8 column. If the column's value is no more than the remaining amount, write 1 and subtract the value; otherwise write 0. Stop after the 1 column. If the remaining amount is 0, the four marks are the pattern; if it is not 0, the number does not fit in four bits.

5 How

  1. Write the headers 8 4 2 1 across your paper and draw a box under each.
  2. To decode, copy the pattern into the boxes, one digit per box. Check that there are four digits and that each is 0 or 1.
  3. Set the total to 0. Working left to right, add the header of every box that holds 1 and skip every box that holds 0.
  4. Stop after the 1 column. The total is your number.
  5. To encode, write the number as the remaining amount. Working left to right, ask whether the header is no more than the remaining amount.
  6. If it is, write 1 in that box and subtract the header from the remaining amount. If it is not, write 0.
  7. Stop after the 1 column. If the remaining amount is 0, read the four boxes as your pattern and keep any leading zeros. If it is not 0, the number does not fit in four bits.
  8. Check by running the rule the other way: decode the pattern you wrote, or encode the number you found, and compare with where you started.

6 Trace

Decode 1010 and encode 6
Place valueBit in 1010ContributionBit in 0110Explanation
8180The first pattern uses 8. The value 6 is too small to use it.
4001Use 4 for the second pattern and leave 2 to make.
2121The first pattern now totals 10. The second totals 6.
1000Neither pattern needs the ones place.

7 The trap

If you read 1010 as one thousand and ten, you have used decimal columns, which step by ten: 1000, 100, 10 and 1. The same four marks then name a much larger number. Binary columns step by two, so 1010 in binary is 8 + 2 = 10.

Three habits guard against this. Write "in binary" next to the pattern, write the headers 8 4 2 1 above the digits before you read, and check that every digit is 0 or 1. A digit from 2 to 9 means the marks are not a binary pattern at all.

Quick checks

Quick check 1 of 2

Decode the four-bit unsigned pattern 1101 using the column headers 8, 4, 2, 1.

Show the steps and the answer
Answer

13

Why: The 8, 4 and 1 columns hold a 1 and the 2 column holds 0, so 8 + 4 + 0 + 1 = 13. Check: encoding 13 gives 1 in the 8 column (remaining 5), 1 in the 4 column (remaining 1), 0 in the 2 column and 1 in the 1 column (remaining 0), which is 1101.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: 5.3 Numbers

Quick check 2 of 2

A sign has four lamps in a row labelled 8, 4, 2, 1. A lit lamp means 1 and a dark lamp means 0, and the sign shows an unsigned number. Reading left to right, the lamps are lit, dark, lit, lit. What whole number does the sign show?

Show the steps and the answer
Answer

11

Why: The pattern is 1011. The lit columns are 8, 2 and 1, so 8 + 0 + 2 + 1 = 11. It is not one thousand and eleven, because the columns step by two, not by ten.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: 5.3 Numbers

Sources

  1. Computer Science Field Guide: 5.3 Numbers. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.

Lesson 3 of 5

Find what fits in three bits

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine a fair booth that prints 000 on its first ticket. Each of the three slots holds one bit, a digit that can be 0 or 1. The width is the number of slots. A fixed width of three means keeping all three digits on every ticket, including zeros on the left.

A pattern is the whole row of digits. When that row identifies a ticket, it is the ticket's code. You can also read the row as an unsigned number, a whole number that is zero or greater. In that reading, 000 is 0 because every slot adds zero.

Write 1 above the rightmost slot and double as you move left. The resulting numbers, 4, 2 and 1 from left to right, are the place values. Add the place values with a 1 underneath, so 010 gives 2 from the middle slot. Keep the place values above your slots so you can look them up as you work.

2 Picture it

3 bits000001010011100101110111

In counting order the patterns are 000, 001, 010, 011, 100, 101, 110 and 111. Each row in the trace gives its unsigned value.

All eight three-bit patterns

3 Why

Each new slot gives every row so far two different endings. Rows that split earlier already differ at the slot where they split. You can find any complete pattern by following its digits from left to right, so each complete row appears once.

The largest unsigned value comes from putting a 1 in every slot. That row adds every place value. Changing any of its digits to 0 takes that place value out of the sum.

4 The rule

Start with one empty row and double the count for each bit you add.

Two choices for each of three positions make eight patterns. The unsigned values run from zero to one less than the pattern count. With three bits they run from 0 through 7.

5 How

  1. Write down the convention, the rule for using the codes. Give each ticket a different three-bit pattern and make every pattern available.
  2. Begin with no digits and fill the slots from left to right. Follow 0 before 1 at each split. Record the row once it has three digits, then go back to the last split with a branch left to follow. Finish when you have followed every branch.
  3. Count the finished rows, including 000. Find the largest unsigned value by adding the place values in the all-ones row.

6 Trace

List every unsigned three-bit code
CodeValueExplanation
0000No place contributes.
0011Only the ones place contributes.
0102Only the twos place contributes.
0113Add two and one.
1004Only the fours place contributes.
1015Add four and one.
1106Add four and two.
1117All three places contribute. All eight patterns have been used.

7 The trap

If you counted seven codes, check where you started. The pattern 000 reads as zero and is one of the eight patterns. If the booth sets 000 aside to mean “no ticket,” it still appears in the list. The booth has seven codes to hand out.

Quick checks

Quick check 1 of 2

The booth sets 000 aside to mean “no ticket.” How many tickets can still get different codes? Can 111 still be used?

Show the steps and the answer
Answer

Seven tickets can get different codes, and 111 is still available.

Why: Of the eight patterns, only 000 is set aside.

Source: University of Canterbury Computer Science Education Research Group, Numbers

Quick check 2 of 2

A locker label has two bit slots. Use each pattern at most once and keep all patterns available. List the labels with 0 before 1 at each split. How many lockers can you label, and what is the largest unsigned value?

Show the steps and the answer
Answer

00, 01, 10, 11. Four lockers. The largest unsigned value is 3.

Why: Each first digit has two choices for the second digit. The two place values are 2 and 1, and 11 uses both.

Source: University of Canterbury Computer Science Education Research Group, Numbers

Sources

  1. Numbers. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.

Lesson 4 of 5

Encode a character as bytes

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine a coat check. The clerk gives your coat a number and writes that number on a ticket.

The letter A is a symbol you can write, called a character. Unicode assigns the character a number called a code point. UTF-8 is an encoding, a rule for writing that number as bytes. A byte is a group of eight bits, each a 0 or a 1.

Read U+0041 as “Unicode code point zero zero four one.” The number after U+ is written in hexadecimal, or hex, a way to write numbers that uses letters as digits too. On paper, write each byte as a pair of hex digits, so C3 A9 reads “C three, A nine” and shows two bytes. Read the space as a gap between byte labels.

Remember the order from character to code point to bytes. Use the two entries in The rule to look up the numbers and byte values.

2 Picture it

UTF-841AC3A9é

A is U+0041 and uses byte 41. The single precomposed é is U+00E9 and uses bytes C3 A9. The three bytes in Aé are 41 C3 A9.

Two code points use three bytes.

3 Why

For the letters here, the code point's number tells you how many UTF-8 bytes to write. In base ten, values from 0 through 127 take one byte and values from 128 through 2,047 take two. Capital A has value 65 and lowercase é has value 233, so they fall in different ranges.

4 The rule

Capital A has code point U+0041.

Its UTF-8 byte is 41. Lowercase é has code point U+00E9. It uses two UTF-8 bytes, C3 first and A9 second.

A base letter followed by a separate combining accent can use two code points, one for the letter and one for the accent. Together they form a combining sequence. Use the single code point U+00E9 for each é in this lesson's inputs.

5 How

  1. Use UTF-8. Start with an empty row and a byte count of zero. Write one box per byte and two hex digits per box.
  2. Read the input from left to right. For each letter, find its code point in The rule. Add that code point's bytes to the right of the row in the order shown.
  3. Stop once you have written the bytes for the last letter. Read the finished row left to right and count the boxes.

6 Trace

Read the UTF-8 bytes for Aé
CharacterCode pointBytes in hexadecimalByte countExplanation
AU+0041411Use one byte for this code point.
éU+00E9C3 A92Use two bytes for this single code point.
AéU+0041 U+00E941 C3 A93Put the bytes in the same order as their code points.

7 The trap

A character count alone leaves the UTF-8 byte count open. AA and Aé each have two letters here. AA takes two bytes, and Aé takes three. Work out how many bytes each code point adds before counting the total.

Quick checks

Quick check 1 of 2

For lowercase é, which is the code point, U+00E9 or C3 A9? How many bytes does it take?

Show the steps and the answer
Answer

U+00E9 is the code point. C3 A9 is two UTF-8 bytes.

Why: U+ introduces the Unicode number. C3 and A9 each label one byte.

Source: Python Software Foundation, Python 3.13 Unicode HOWTO

Quick check 2 of 2

Write the UTF-8 bytes for éAé in order. How many bytes are there?

Show the steps and the answer
Answer

C3 A9 41 C3 A9 is five UTF-8 bytes.

Why: The first é adds two bytes, A adds one, and the last é adds two more.

Source: University of Canterbury, Computer Science Field Guide: Text

Sources

  1. Python 3.13 Unicode HOWTO. Python Software Foundation. Python Software Foundation License Version 2. Read 25 Nov 2026.
  2. Computer Science Field Guide: Text. University of Canterbury. CC BY-SA 4.0. Read 25 Nov 2026.

Lesson 5 of 5

Decode a tiny bitmap

Subject: ComputingOpen this lesson
Leans on 0Comes back in 0

1 In plain words

Imagine leaving a note for a friend about two squares side by side on a calendar. Agree that 1 means shade a square dark and 0 means leave it white. Read 10 from left to right. Shade the first square and leave the second white.

A bit can have either of two values, written 0 or 1. Here, the bit stream is the line of bits you read in order.

A picture can be made from a grid of coloured spots called pixels. In our paper bitmap, each pixel is one square with a colour set by one bit. To decode it, use the bits to draw the picture.

A row goes across and a column runs down. Look up the width (how many columns), height (how many rows), and key (which bit means which colour). The width and height are the picture's dimensions. In this paper format, read in row-major order. Finish one row before you start the next.

2 Picture it

100110Grid AGrid B

The three-column grid has rows 100 and 110. The two-column grid has rows 10, 01 and 10. Reading either grid row by row gives 100110.

Six bits arranged into two shapes

3 Why

In this paper bitmap, each square has two possible colours, and a bit has two possible values. Give each colour its own value and one bit is enough to tell you how to colour a square.

To get the bits back, follow the same path and use the key in reverse. When you see ink, write the bit that meant ink. When you see white, write the bit that meant white.

4 The rule

The paper format is the set of rules that tells you how to read the bits.

It gives you the width, height, colour key and reading order. Both dimensions are whole numbers of at least one. Multiply the width by the height to count the squares. You need exactly that many bits, including every 0.

For the two grids shown here, the key is 1 for ink and 0 for white paper. Start with an all-white grid and the first bit. Work across each row from left to right, starting with the top row. Stop when you use the last bit in the bottom-right square.

5 How

  1. Draw the given number of columns and rows. Leave all squares white. Count the squares and the bits. If the counts differ, stop before shading and report the two counts.
  2. Start at the top-left square with the first bit. Use the key to decide whether to shade the square or leave it white.
  3. Use the next bit in the next square to the right. At the end of a row, move to the leftmost square of the next row down if there is one. Stop after you use the last bit in the bottom-right square.
  4. Read the drawing back from the top left in the same order. Use the key to write one bit per square and join the rows into one line with no spaces.

6 Trace

Read both layouts back
ColumnsRows top to bottomRecovered bitsExplanation
3100 / 110100110The fourth bit starts the second row.
210 / 01 / 10100110Bits three and five start new rows.

7 The trap

Use the width to decide where to end each row. Grid A needs three bits across each of its two rows. If you use the height of two as the row length and lay out all six bits, the third bit starts a new row and you get Grid B. Check the key as well. If you swap what 0 and 1 mean, every ink square becomes white and every white square becomes ink.

Quick checks

Quick check 1 of 2

Draw 01001110 with 4 columns and 2 rows, using 1 for ink and 0 for white paper. What are the bits in each row?

Show the steps and the answer
Answer

0100 / 1110.

Why: Put the first four bits on the top row and the next four below. The first 0 uses the first square, which stays white.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: Images and Colours

Quick check 2 of 2

A two-column picture has these rows from top to bottom, each written left to right: white and ink, ink and white, ink and ink. This time the key is 0 for ink and 1 for white. What bit stream do you get?

Show the steps and the answer
Answer

100100.

Why: The rows read 10, 01 and 00 under this key. Join them in that order.

Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: What's the big picture?

Sources

  1. Computer Science Field Guide: What's the big picture?. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.
  2. Computer Science Field Guide: Images and Colours. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 25 Nov 2026.