Lesson 5: Overflow and Rounding

Unplugged | Concept Invention


Students extend their understanding of the binary number system by exploring errors that result from overflow and rounding. They use the binary odometer widget and make a "flippy do pro" to practice binary-to-decimal number conversions which include fractional place values.


This lesson introduces students to the practical aspects of using a binary system to represent numbers in a computing device. Students discover the limitations of creating numbers that are “too big” or “too small” to count. They learn that, while a number system is infinite, the physical representation of numbers requires place values -- which are finite, and limit the ability to represent numbers.


Lesson Modifications

Warm Up (5 mins)

Activity (35 mins)

Wrap Up (5 mins)

View on Code Studio


Students will be able to:

  • Describe how to include fractions in the binary number system.
  • Understand that overflow and roundoff errors result from real-world limitations in representing place value.


  • Print copies of the Flippy Do Pro, 1 per group
  • Scissors


Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

For the Students

Teaching Guide

Lesson Modifications

Attention, teachers! If you are teaching virtually or in a socially-distanced classroom, please read the full lesson plan below, then click here to access the modifications.

Warm Up (5 mins)

Discussion Goal

Today we’re going to explore what happens when you don’t have the right “places” to store information. This can happen when you try to store very large numbers, very small ones, and everything in-between! The goal of the prompt is to understand the very real problem of making sure that enough place values are available to represent numbers.

  • The largest amount of change you can give someone is $99.90.
  • The least change you can give is $0.10.
  • You can’t give someone $0.07. You also can’t give someone $1.25 in change (because you have no nickels!)

At both extremes of the number range, large and small -- and in between numbers -- you are unable to build some numbers because you don’t have the place values to do so.

Prompt: Imagine you work at a local store. In the register all you have are nine $10 bills, nine $1 bills, and nine dimes.

  • What’s the largest amount of change that you can give someone?
  • What’s the least?
  • What would you do if someone needed 7 cents in change?

Activity (35 mins)

Group: Place students in groups of two. Groups will need one computer per group.

Odometer Activity

Teaching Tip

Students will tackle the problem of “running out of place values” when counting to bigger and bigger numbers. They will play with a digital odometer widget to explore what happens when you add one to the largest number you can represent in a number system.


We will start exploring large place values to see what happens when a big number gets too big. Go to the Binary Odometer Widget on Level 2 of the lesson on Code Studio.

This is a widget that simulates a car odometer - a device that tracks how far the car has driven (in miles or kilometers). Explore the odometer to understand how it works.

Do This: Navigate to Level 2. Play with the odometer to figure out how it works.

Circulate: Give students two to three minutes to explore the odometer.


Now I'm going to give you a challenge to tackle with the Binary Odometer. Write your response in your journals.

Do This: Set the binary odometer to the highest number possible. Then let it run!

Discussion Goal

When the odometer turns over -- exceeds the number of place values it can physically display -- the odometer reading correctly shows all but one number in its place value positions.

For example:

After the odometer turns over:

As you can see, all the numbers should flip to 0 and the one of the left should flip to 1. But we are out of place values! So the numbers flip to 0, but nothing flips to 1. The number we are trying to represent does not fit in the number of bits we have available to accurately display it.

Like a bathtub that has reached its maximum capacity for holding water and is now overflowing, the odometer has reached its maximum capacity and has reached overflow.


  • What happens to the odometer reading?
  • Does the odometer still show the distance driven by the car?

Flippy Do Pro


Now that you have started thinking about place value and overflow, we are going to work on a different problem. What happens when there aren’t enough place values to represent a number? You will explore this with a new version of the Flippy Do, the Flippy Do Pro!

Distribute: Provide each group with a copy of the Flippy Do Pro Template and scissors.

Do This: Cut and fold your Flippy Do Pro following the guidance on the slide. Fill out all the numbers if they are not already done.

Teaching Tip

  • The Flippy Do Pro is still using 8 bits to represent a number. But this time, the place value of each bit has been assigned in a different way than in the previous Flippy Do or on the Binary Odometer. The bits have been "shifted" to the right two times. The value 1 (2^0) is no longer the smallest place value. The value of a bit just to the right of 1 (2^0) is 0.5, which is 2^-1. The value to the right again is 0.25 which is 2^-2.
  • Students may struggle with negative exponents. What's more important than emphasizing the math is emphasizing the pattern of place values in the Flippy Do Pro. As you move left, the place value doubles. As you move right, the place value halves.
  • Help students see that using the Flippy Do Pro is similar to using the Flippy Do. To form a value, flip the flaps up or down at the bottom of the device to create a sequence of zeros and ones. Note that the range of place values is limited by the largest bit value, 2^5 which is 32, and the smallest bit value, 2^-2 which is 0.25. As with the Flippy Do, adding together all the values for each place value containing a "1" produces the total value represented on the Flippy Do Pro.

Teaching Tip

When referring to the Flippy Do Pro, we are using a vertical line to indicate the difference between the fractional part and the whole part of a number being represented. Using language in a clear way can be tricky for this lesson because “decimal” can mean different things to students. For example, students frequently refer to a number as a “decimal” if it isn’t a whole number (ex. Students may call “1.23” a “decimal”) but here we want to stick with students thinking as a decimal number to be a “base 10” number. Therefore, we avoid using the word “decimal point” in the Flippy Do Pro and instead talk about the fractional part of the number and the whole part of the number. The purpose of doing this is to maintain using "decimal" to only refer to a "base 10" number. For your own personal knowledge, you can read more about "decimal points" and "binary points" on Wikipedia.


The Flippy Do Pro is similar to the one you made before. But this time, the Flippy Do Pro is already filled with binary place values assigned in a different way -- they include fractions.

When using the Flippy Do Pro, the numbers on the left-hand side of the line are whole numbers and those on the right-hand side of the line are fractional numbers.

Flippy Do Pro Challenges

Challenge #1 - Smallest Non-Zero Number: Produce the smallest non-zero binary number possible with the Flippy Do Pro.

  • The smallest binary number students produce is 000000.01 and this number has a decimal value of 0.25.

Challenge #2 - Next Value: Increase the number made in Challenge #1 to the next possible value.

  • The binary number students produce is 000000.10 and this number has a decimal value of 0.50.

Challenge #3 - Got Quarters? Make the values 0.25, 0.50, and 0.75 one after another.

  • The binary numbers students produce are 000000.01, 000000.10, 000000.11. Note the pattern of changing a place value from 1 to 0 and then "carrying" the one.

Challenge #4 - Can't Make Change: Make all the fractional possible in binary using the Flippy Do Pro.

  • There are no new values besides those made in Challenge #3 because there are no place values for representing other fractions.
  • Note, if students need a concrete example for Challenge #4, have them try to make 39 cents in binary. It can't be done with the values they have available in the Flippy Do Pro.

Challenge #5 - Largest Number: What is the largest number (in decimal) you can make with the Flippy Do Pro?

  • With all of the bits flipped to 1, the largest number you can make is 63.75. Note that this is smaller than the largest you can make with a traditional Flippy Do, which is 255. This is because we have shifted two bits to represent smaller numbers (0.5 & 0.25).

Challenge #6 - How Much Pie:

Challenge 6 contains a number of slides. Preview these slides before class to understand when to click through to the next slide.

This challenge is contained on a series of slides. Students use a Flippy Do Pro to determine how much pie is left at the end of dessert. With each slide, allow time for students to decide how to represent the amount of pie left as a binary number, then convert that to decimal and write it down in the journal. In this challenge it is expected that students will estimate and do some rounding when determining how much pie is left.

  • Add all the decimal numbers up together. Compare with a partner and discuss.
  • Show the example of one possible answer. Click to the next slide to show these totals added together.


In our final challenge, your answer may be different than your classmates. It comes down to how you rounded - did you decide to round up or round down with the various amounts of pie. If we did not have to round, the answer would be exactly one pie left over. You may have come to the same conclusion by rounding - or not!

Discussion Goal

Goal: Computers rely on precision. Think of a calculator. We depend on 1+1 always equaling 2. Rounding is necessary because of the limits of bits, but can lead to errors.

Prompt: Why is it a problem for a computer if your answers are different than others?

Wrap Up (5 mins)


The most important takeaway from this lesson is to understand that bits can represent a limited amount of information.

Discussion Goal

As students have seen, you can make “any number” in your head, but the tool you use to represent a number has limitations. It has a fixed number of place values it can show. The odometer keeps running after you move beyond its upper limit, but the largest place values cannot be displayed due to overflow error.

In the Flippy Do Pro, you assigned some of the bits to fractions, but you saw that you still couldn’t represent certain “small” numbers -- you could only show a number that was “close to” your target number. This is roundoff error, an error that occurs when bit arrangements can’t represent numbers as intended.

Ultimately, regardless of the size of our odometer or Flippy Do Pro, and how many bits we add to them, there’s going to be numbers that are too large, too small, or “in-between” the values we want to represent.


  • What does the binary odometer show about representing large numbers?
  • What does the Flippy Do Pro show about representing very small numbers?
  • If we had a big enough odometer or Flippy Do Pro, could we represent every possible number?

Journal: Students add to their journals the definitions for: Overflow Error and Round-off Error.

Assessment: Check For Understanding

Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.

Question: Modern car odometers record up to a million miles driven. What happens to the odometer reading when a car drives beyond its maximum reading?

Question: When using bits to represent fractions of a number, can you create all possible fractions? Why or why not?

  • Check Your Understanding
  • 2
  • 3
  • (click tabs to see student view)
View on Code Studio

Student Instructions

View on Code Studio

Student Instructions

In 50 words or less, describe the concept of a number system.

Why are rules required for a number system to be useful?

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

DA - Data & Analysis
  • 3A-DA-09 - Translate between different bit representations of real-world phenomena, such as characters, numbers, and images.


DAT-1 - The way that the computer represents data is different from the way that the data are interpreted and displayed for the user
DAT-1.B - Explain the consequences of using bits to represent data.
  • DAT-1.B.1 - In many programming languages, integers are represented by a fixed number of bits, which limits the range of integer values and mathematical operations on those values. This limitation can result in overflow or other errors.
  • DAT-1.B.2 - Other programming languages provide an abstraction through which the size of representable integers is limited only by the size of the computer's memory; this is the case for the language defined in the exam reference sheet.
  • DAT-1.B.3 - In programming languages, the fixed number of bits used to represent real numbers limits the range and mathematical operations on these values; this limitation can result in round-off and other errors. Some real numbers are represented as approximations i