Lesson Plan

Lesson Plan
Grade: Date: 18/01/2026
Subject: Computer Science
Lesson Topic: Show understanding that binary representations can give rise to rounding errors
Learning Objective/s:
  • Describe the components of a binary floating‑point representation (sign, exponent, fraction).
  • Explain why many decimal fractions cannot be represented exactly in binary and how this leads to rounding errors.
  • Analyse the impact of rounding errors on calculations such as repeated addition and equality tests.
  • Apply simple strategies (integer arithmetic, explicit rounding, tolerance comparisons) to mitigate rounding errors in code.
Materials Needed:
  • Projector or interactive whiteboard
  • Slides showing IEEE‑754 format and binary conversion examples
  • Worksheet with conversion and rounding‑error exercises
  • Computers with Python (or an IDE) for running code snippets
  • Calculator or online binary converter
  • Handout summarising mitigation strategies
Introduction:

Begin with a quick demonstration of adding 0.1 ten times in Python and ask students what result they expect. Recall previous learning on binary numbers and integer representation. Explain that today they will explore how binary floating‑point representation can introduce subtle rounding errors, and by the end of the lesson they will be able to identify and mitigate these errors.

Lesson Structure:
  1. Do‑now (5') – Students run a short Python script that adds 0.1 ten times and record the output; teacher checks answers.
  2. Mini‑lecture (10') – Review binary normalised form and IEEE‑754 fields using slides; highlight the implicit leading 1 and exponent bias.
  3. Guided conversion activity (12') – In pairs, convert –13.625 to single‑precision IEEE‑754, completing a worksheet.
  4. Demonstration of rounding errors (8') – Show why 0.1 cannot be represented exactly in binary and discuss the repeating pattern.
  5. Group investigation (10') – Students predict and then observe the result of summing 0.1 ten times; discuss accumulation and comparison pitfalls.
  6. Mitigation strategies (8') – Present and practice integer arithmetic, explicit rounding, and epsilon‑tolerance comparisons in code.
  7. Quick check (5') – Exit ticket: write one example where floating‑point rounding could cause a bug and a strategy to avoid it.
Conclusion:

Summarise that floating‑point numbers consist of sign, exponent and fraction, and that binary cannot exactly represent many decimal fractions, leading to rounding errors that can accumulate. Remind students of the mitigation techniques discussed and collect the exit tickets. For homework, assign a worksheet converting several decimals to IEEE‑754 and identifying potential rounding issues.