Learning Rooms/○ Level 3 · Innovator/Computing and algorithms
Floating Point Numbers - Computerphile
Computerphile · Length: see YouTube · captions on YouTube · nothing loads until you press play
By the end you can…
- Explain why many decimal fractions cannot be stored exactly in binary.
- Predict when floating-point error appears and how it accumulates in a loop.
- Compare floats with a tolerance (math.isclose or abs(a − b) < tol) instead of ==.
Watch it all: no segment has been checked by hand for this video yet.
1.Predict before you press play
What does Python print for 0.1 + 0.2?
Pick one before you press play. A wrong guess is fine: it is what makes the video stick.
2.See the idea first
Play with this diagram for a minute. It gives you something to hang the video on.
Loading the interactive…
Can't use the diagram? Read a description instead
The float explorer adds 0.1 to a total n times and prints the result as Python does: n = 1 gives 0.1, n = 2 gives 0.2, n = 3 gives 0.30000000000000004 (== 0.3 is False, math.isclose is True), n = 8 gives 0.7999999999999999. A second panel shows the exact stored values: 0.1 is 0.1000000000000000055511151231257827021181583404541015625, while 0.5 and 0.25 are exact.
3.Watch, actively
Explains how computers store fractional numbers in binary, and why some simple decimals can only be stored approximately.
Length: see YouTube · captions on YouTube · source
Nothing loads from YouTube until you press play.
Watch for…
- → Listen for why some fractions repeat for ever in a given number base, and what the computer does when it runs out of digits.
Pause whenever you like. Rewatching a hard minute is a good habit, not a failure.
Can't stream it? Read the idea instead
Computers store fractional numbers in binary with a fixed number of digits. Just as one third never ends in decimal, one tenth never ends in binary, so it is stored as the nearest value that fits, and small rounding errors appear in sums like 0.1 + 0.2.
What the video covers (our own note, written when we verified it): Explains how computers store fractional numbers in binary, and why some simple decimals can only be stored approximately.
Written by Tactiverge in our own words, not a transcript. The full lesson below explains the idea without the video.
Jot down one thing that surprised you and one question you still have.
4.Practise what you just saw
These come from the lesson that use this video and are checked on the server. Wrong answers get a hint and another try.
Practice 1 · a fresh version every time
A regulator should output 2.5 V. A test reads 2.502 V. What is the absolute error, |measured − expected|, in millivolts?
Practice 2
What does print(0.1 * 3 == 0.3) show?
Practice 3
A timer adds 0.1 s every tick. What is the most reliable design?
Practice 4
Which test is the right way to check that a computed voltage v is 3.3 V?
5.Try it yourself
No simulation models this idea yet. The lesson below has an interactive diagram instead.
6.Build something with it
Follow-up project
Write a program that adds 0.1 one thousand times in a float and also counts ticks in an int. Print both totals, their difference, and whether math.isclose says they match. Write one sentence on which you would trust in a timer.
Where this video lives
- Why 0.1 + 0.2 is not 0.3 · Level 2, week 3
In the course catalogue: CSE-210 Python for engineers
The video is by Computerphile, embedded from YouTube with privacy-enhanced mode and never autoplayed. The room around it (prompts, notes, practice, projects) is Tactiverge's, written with AI assistance and checked by automated tests only.