← Back to course
Intro to CS 9-10 / Week 09 / Wednesday
3/6
Week 09 · Bits and Binary

Wednesday

Beacon Lab: Bit cards and a curve
// Place values, one byte, overflow, and sampling a smooth curve
⏱ about 20 min

Wednesday: Beacon Lab: Bit Cards and a Curve

Beacon's reading counter has been ticking up all day. Comet checks it: 255 readings.

"One more reading," she says, and taps the counter. Nothing changes. Then an error light blinks.

Wren frowns. "It only has eight bits. 255 is the biggest number it can hold."

Nova projects eight cards, all face up. "Interesting," she says. "Where would the next card go?"

Comet looks at the empty space to the left. "There is no ninth card. That is an overflow!"

Wren pins a temperature chart beside the counter. "And after that, let's see how Beacon stores a smooth curve."

Your mission

Part 1: make eight bit cards, encode Beacon's readings, and find the overflow.

Part 2: sample a smooth temperature curve on graph paper.

  • 8 index cards or paper squares
  • A pencil and a marker
  • Graph paper, or plain paper and a ruler
  1. Write one place value on each card: 128, 64, 32, 16, 8, 4, 2 and 1.
  2. Lay the cards in a row with 128 on the left. Face up means 1. Face down means 0.
  3. Encode the morning water reading, 75. Turn up 64, 8, 2 and 1.
  4. Encode the light reading, 90, then the temperature reading, 42. Write each byte down.
  5. Turn every card face up. Read the number, then try to add 1 more.
PART 1: ENCODE AND OVERFLOW
  • Read the question.
  • Tap your answer.
Which cards are face up for the light reading, 90?
Which byte is the temperature reading, 42?
All eight cards are face up. What number do they show?
You add 1 to 255. The answer, 256, is outside the range. What kind of error is that?

Part 2: sampling a smooth curve

Analog data have values that change smoothly over time, like the pitch and volume of music or the colors of a painting.

The greenhouse temperature rises and falls smoothly through the day.

Sampling measures an analog signal at regular intervals, called samples. Digital samples can closely approximate analog data.

Using digital data to approximate real-world analog data is an example of abstraction.

  1. Draw a time axis from hour 0 to hour 24, and a temperature axis from 0 to 100.
  2. With a light pencil, sketch a smooth curve that starts low, rises to a peak in the afternoon, and falls again.
  3. Now plot only the samples in the table below, one dot every 4 hours.
  4. Connect the dots with straight lines. Compare them with your smooth curve.
  5. Add a dot halfway between two samples where the lines miss the curve the most.
Hour04812162024
Temperature reading20183052604122
READ YOUR SAMPLED CURVE
  • Read the question.
  • Tap your answer.
Sampling every 4 hours from hour 0 to hour 24, how many samples are there?
Which sampled hour has the highest reading?
Which byte stores the peak reading, 60?
If Beacon sampled every 2 hours instead, what would happen?
What the lab showsTrue or false?
Eight bit cards can show any whole number from 0 to 255.?
Eight bit cards can show 256.?
Straight lines between samples match the smooth curve exactly.?
Sampling more often gives a closer approximation.?
WHY THIS EXERCISEBits limit the range of numbers, and samples only approximate a smooth curve.

Excellent lab work. Tomorrow you will see one byte mean three different things.

← Tuesday