A byte arrives from the relay: 00000011. Comet converts it at once. "It is 3."
"3 what?" Wren asks. "Three tomatoes? Three degrees? Three o'clock?"
Comet opens Beacon's message code sheet. "In the message code, 00000011 means all plants are fine."
"So the same bits can mean a number or a message," Wren says. "What do you notice?"
Nova projects the byte three times, each with a different label above it. "The bits do not change," she says. "The context does."
Comet scribbles a note on the sheet: "Always send the label with the bits."
Bits are grouped to stand for abstractions such as numbers, characters and colors.
The same sequence of bits can stand for different types of data in different contexts.
Beacon uses three small codes the crew invented for practice. Real computers use their own, much larger codes.
| Code | What a byte stands for | Example |
|---|---|---|
| Number | A whole number from 0 to 255 | 00000011 is 3 |
| Beacon message code | One of the crew's alert messages | 00000011 is "All plants are fine" |
| Crew letter code | A letter: A is 1, B is 2, and so on to Z, 26 | 00000011 is the letter C |
| Beacon photo code | One pixel's brightness, 0 dark to 255 brightest | 00000011 is a very dark pixel |
In many programming languages, whole numbers are stored in a fixed number of bits. That limits their range and can cause overflow errors.
Real numbers, like 2.5, are also stored in a fixed number of bits. This can cause round-off errors.
Some real numbers can only be stored as approximations.
An example from math class shows the idea. One third as a decimal is 0.333, with threes that never end. Any fixed number of digits can only hold an approximation of it.
| Statement | True or false? |
|---|---|
| The same bits can mean a number in one context and a letter in another. | ? |
| A fixed number of bits can hold any whole number, however large. | ? |
| Some real numbers are stored as approximations. | ? |
| The crew letter code is the code real computers use. | ? |
Great decoding. Tomorrow you will ask who gets to use these bits at all.