← Back to course
Intro to CS 9-10 / Week 09 / Thursday
4/6
Week 09 Β· Bits and Binary

Thursday

Same bits, different meanings
// Place values, one byte, overflow, and sampling a smooth curve
⏱ about 20 min

Thursday: Same Bits, Different Meanings

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."

Context gives bits their meaning

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.

CodeWhat a byte stands forExample
NumberA whole number from 0 to 25500000011 is 3
Beacon message codeOne of the crew's alert messages00000011 is "All plants are fine"
Crew letter codeA letter: A is 1, B is 2, and so on to Z, 2600000011 is the letter C
Beacon photo codeOne pixel's brightness, 0 dark to 255 brightest00000011 is a very dark pixel
DECODE IN CONTEXT
  • Read the question.
  • Tap your answer.
In the crew letter code, which letter is 00001000?
In the crew letter code, 00001000 then 00001001 spell what?
In Beacon's photo code, which byte is the brightest pixel?
What tells you whether 00000011 means 3, C, or a message?

Limits of fixed bits

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.

StatementTrue 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.?
WHY THIS EXERCISEContext gives bits meaning, and fixed bits set limits on what can be stored.
An error from storing a real number as an approximation is a ____ error.
The same bits can mean different things in different ____.
Try it
Use the crew letter code to write a three-letter greeting as three bytes.
Swap it with a family member or friend and see if they can decode it.
What kind of data changes smoothly, like the pitch of music? Type one word.
WHY THIS EXERCISEAnalog data must be sampled before a computer can store it as bits.
On paper, draw one byte, 00010011, in a box. Around it, write what it would mean as a number, in the crew letter code, and as a pixel.

Great decoding. Tomorrow you will ask who gets to use these bits at all.

← Wednesday