An Agreed Code: How the Same Bits Mean Letters or Colours
Bits need a rule for interpretation. The same pattern can represent a letter or a colour under different codes. To communicate an intended message, sender and receiver need matching rules for the code and how the bits are grouped.
What a learner can do afterwards
- Invent a code for a small set of symbols and use it to send a short message to someone holding the same code
- Show what comes out when the two ends use different codes for the same bits
- Give two things the same bit pattern could stand for in two different files
1 · Read
You have met bits and bytes as patterns of two states. To interpret a pattern as a message, you need a code: a rule linking patterns to symbols or values. The same bits can have different meanings under different codes. Sender and receiver need matching rules, including how to group the bits. An ordinary code for representing data does not have to keep it secret.
For a four-letter practice code, use 00=A, 01=B, 10=C and 11=D. Each letter has a different two-bit pattern. To send DC, replace D with 11 and C with 10: send 11 10. To read it, split it into two-bit groups and use the table in reverse. To invent a code, list the symbols, give each a different pattern, and share the table and group size.
Now define a different practice code for four shades: 00=black, 01=dark grey, 10=light grey and 11=white. Under the letter code, 01 means B. Under the shade code, 01 means dark grey. Real file formats also give rules for interpreting bits, but not every byte in an image directly describes a colour, and not every character uses just one byte.
If unchanged bits arrive but the receiver uses a different table, the output can differ from the intended message. Check the tables and grouping rules. A readable output alone does not prove that a cable works correctly. To rule out a changed message in an example, we must be told that the received bits match the sent bits.
A shared rule can still be ambiguous. A rule that sends word lengths turns both 'go home' and 'be kind' into 2, 4. Knowing that rule does not tell the reader which phrase was sent. For our four-letter code, different letters have different patterns, so each two-bit group has one listed reading.
A fixed-size code says how many bits make one symbol. Start at the left and separate groups of that size. Keep every bit in order. With three bits per symbol, 110010 becomes 110 010. Splitting it into pairs would use a different grouping rule.
Use the stated code and grouping rules to interpret bits. Matching rules help readers recover a message, but an ambiguous code can still leave more than one reading.
Lesson, questions and flashcards written for this dataset using original practice codes.
Five computing readings written for this dataset using original examples.
More to read
Agree on the message rules
A club uses two-bit labels for rooms: 00 means hall, 01 means studio, 10 means kitchen and 11 means library. Someone sends 01 11 to list studio, then library. The reader needs the room table and the instruction to read two bits at a time. The patterns alone do not tell the reader that these are room names. Sharing a table without its grouping rule leaves part of the message rule unstated.
Make a small direction code
List four directions: north, east, south and west. Assign each a different two-bit pattern, such as 00, 01, 10 and 11 in that order. Write the table down. To send north followed by west, use 00 11. Give the reader the table and the two-bit group size. If you assign one pattern to two directions, that group no longer tells the reader which direction you chose.
A number or a label?
On a worksheet, 24 may be a number to add. On a classroom plan, 24 may be a label for a cupboard. Seeing the symbols does not tell you which use was intended. Look at the stated rules and the task. Computer data also needs interpretation rules. A rule for reading a value is different from a rule that asks you to add it, display it or use it as a label.
Where does each group end?
Consider the six bits 000110. With two-bit groups, you read 00, 01, 10. With three-bit groups, you read 000, 110. Those are different lists of patterns, even though no bit changed. A message format must tell the reader how to find the groups. Spaces in a classroom example make the grouping visible; software needs a stated rule rather than a guess about where each symbol ends.
A code can be public
A bit code can be shared openly so readers know how to interpret data. Its job may be to represent letters or shades, not to hide them. If everyone has our four-letter table, everyone can read messages made with it. Calling a rule a code does not tell you whether it keeps a message private. Ask what the rule does and who can use it.
2 · Watch
به انگلیسیTake it off screen
Where it sits
Where this leads
Jobs that lean on this skill. Follow one to see everything it is built on.
8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.