Skip to main content

Pilot · L07 · 50 minutes

Representing information in bits

Read unsigned binary using place values, reason about what a fixed number of bits can store and what happens on overflow, and explain why sampled, rounded data approximates a continuous original and why every bit pattern needs an agreed interpretation.

Topics: 2.1 Binary Numbers

Goals and vocabulary

By the end you can:

  • Explain that the same bits can mean different things and that a convention decides the meaning.
  • Convert small unsigned binary values to decimal and back.
  • Give the range of values a fixed number of bits can store and describe overflow under a stated convention.
  • Explain how sampling and round-off make stored data an approximation of a continuous original.
  • Predict the effect of adding one bit.
Bit
A single binary digit, 0 or 1.
Place value
The amount a position is worth; in binary each position is worth twice the one to its right.
Overflow
A result needs more bits than are available to store it.
Sample
A measurement of a continuous quantity taken at one moment.
Round-off
Storing the nearest value the bits allow instead of the exact value.
Convention
An agreed rule for what a bit pattern represents.

Bits mean nothing without a convention

A bit is a single 0 or 1. A row of bits is just a pattern until a convention says how to read it. The same eight bits can be a number, a letter, part of a colour or one sample of a sound, depending on what the program that stores and reads them has agreed.

One pattern, three conventions
BitsRead as an unsigned whole numberRead as a letter code (ASCII)Read as a grey level from 0 (black) to 255 (white)
0100000165Aa dark grey

Nothing in the bits themselves says which reading is right. If a program reads a file with the wrong convention, it gets nonsense, even though every bit is intact.

Positional binary: place values that double

In this lesson binary means unsigned whole numbers. Each position has a place value twice the one to its right: 1, 2, 4, 8, 16 and so on. To convert to decimal, add the place values of the positions that hold a 1.

Converting 1101 to decimal
Place value8421
Bit1101
Contributes8401

8 + 4 + 0 + 1 = 13. Going the other way, start with the largest place value that fits: 13 contains one 8 (leaving 5), one 4 (leaving 1), no 2 and one 1, so 13 is 1101. Leading zeros do not change the value: 001011 is 8 + 2 + 1 = 11.

A fixed number of bits limits the values

Real systems store numbers in a fixed number of bits. With n bits there are 2ⁿ different patterns, so an unsigned value can range from 0 to 2ⁿ − 1. Four bits give 16 patterns, from 0000 (0) to 1111 (15).

Bits and representable unsigned values
BitsPatternsRange
380 to 7
4160 to 15
5320 to 31
82560 to 255

Adding one more bit doubles the number of patterns. It does not just add one more value.

Sampling continuous things

Some information is already discrete: a count of students, a letter. Other things, like a sound wave or a temperature through the day, vary continuously. To store them in bits, a program takes samples: it measures at regular moments and stores each measurement with a fixed number of bits.

  • Between samples, the program has no data. Changes that happen between two samples can be missed.
  • Each measurement is rounded to the nearest value the bits can store. This round-off means the stored value is close to, but not always exactly, the original.
  • Sampling more often, or using more bits per sample, gives a closer approximation but uses more storage. It never makes the stored version identical to the continuous original.

Worked example: storing a fictional thermometer reading

Worked example

A fictional classroom sensor records the temperature once every hour and rounds each reading to the nearest whole degree and stores it in five bits (0 to 31).

Three hourly samples
TimeActual temperatureStored valueBits
09:0019.4 °C1910011
10:0021.6 °C2210110
11:0022.1 °C2210110
  • Round-off: 19.4 is stored as 19 and 21.6 as 22. The decimal part is lost.
  • Sampling: if the heater briefly pushed the room to 25 °C at 10:30, the stored data would never show it.
  • Width: a reading of 33 °C cannot be stored in five bits. Under this lesson’s convention the sensor reports an overflow error.
  • Interpretation: 10110 means 22 °C only because the sensor’s documentation says “unsigned whole degrees”.

Explore each concept

Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.

  • Analog versus digital
  • Sample intervals and rounding
  • Bits, bytes and conventions
  • Fixed-width versus AP integer model
Open this example on its own

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to explore: Sampling, precision and bit interpretation
  1. ExploresamplingWaiting
  2. Sampling interval1Waiting
  3. Stored precisionwholeWaiting

Ready to explore: Sampling, precision and bit interpretation

Why: Change an input, predict the first effect, then advance one step.

Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.

Step through and experiment

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 145Waiting
  2. Input 26Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try 63 and 64, then change the width.

Common misconceptions

  • Bits carry their own meaning

    The belief: 01000001 is always the letter A.

    What is actually true: It is 65 as a number and A only under a letter-code convention. The reader must know the convention.

    Check yourself: Which convention does the program reading this file use?

  • One more bit means one more value

    The belief: Five bits can store one more value than four bits.

    What is actually true: Each extra bit doubles the number of patterns: 16 becomes 32.

    Check yourself: How many patterns do four bits give, and what happens when you double that?

  • Digital data is exact

    The belief: A stored recording is identical to the real sound.

    What is actually true: Sampling and round-off make it an approximation; more samples or bits get closer but never identical.

    Check yourself: What happens between two samples?

Guided practice

Guided: four-bit cards

Use four cards labelled 8, 4, 2 and 1. A card face up is 1 and face down is 0.

Work in pairs. One partner calls a decimal number from 0 to 15; the other shows it with the cards and reads the bits aloud.

  1. Show 13 and write its bits.
  2. Show 6 and 9, then explain why their bits are each other’s opposite.
  3. Try to show 16. Explain what goes wrong, and state what this lesson’s overflow convention says happens.
  4. Add a fifth card. Write its place value and the new largest value.

Independent practice

Independent: the fictional sensor

Use the worked thermometer example.

  1. Convert 10011 and 10110 to decimal and check them against the table.
  2. Give the bits that would be stored for a reading of 26.7 °C, and explain the round-off.
  3. Explain why the 10:30 heater spike is missing from the stored data.
  4. Explain what happens to a reading of 33 °C and how many bits would be needed to store it.

Exit check

  1. Convert 10101 to decimal and show the place values you used.
  2. A program reads the bits 01000010 and shows the letter B. Another program reads the same bits and shows 66. Explain how both can be correct.

Check yourself

Practice only: answers are checked in your browser and nothing is saved or sent to your teacher. Each explanation links back to the section it practises.

Lesson practice

  1. Question 1 of 4A file contains the bits 01000001. One program displays the letter A; another displays the number 65. What explains this?

    Select one answer.

  2. Question 2 of 4A fictional sensor records the temperature once every hour. Which statement compares the stored data with the real temperature correctly?

    Select one answer.

  3. Question 3 of 4A score is stored as an unsigned whole number in four bits. Under this lesson’s convention, what happens when 15 + 1 is stored?

    Select one answer.

  4. Question 4 of 4A thermometer reads 21.6 °C. It is rounded to the nearest whole degree and stored as a whole number. Which two statements are correct? Select two.

    Select exactly two answers (0 of 2 selected).

Your practice so far

Check an answer to see its rationale.

Apply it somewhere new

  1. Question 1 of 3What is the unsigned binary value 001011 in decimal?

    Select one answer.

  2. Question 2 of 3Which four-bit pattern represents the decimal value 13?

    Select one answer.

  3. Question 3 of 3A system stores unsigned values in four bits. It is changed to five bits. What is the effect?

    Select one answer.

Your practice so far

Check an answer to see its rationale.