PeerTube de WeKeys

Why 0.1 + 0.2 Doesn't Equal 0.3 - Floating Point Explained


Listen Later

Why does Python tell you that 0.1 + 0.2 = 0.30000000000000004?

The answer is IEEE 754 - the floating-point standard baked into every CPU on the planet.

In this video we go under the hood: from the limits of fixed-point arithmetic, through scientific notation in binary, to hand-converting 3.14 into its 32-bit IEEE 754 representation - and then proving it in C with a union hack that reads the raw bits directly out of memory.

We also look at what happens at the edges: divide by zero, and rather than a crash you get infinity. Divide zero by zero and you get NaN - Not a Number. IEEE 754 doesn't just define the happy path, it defines all the weird paths too.

━━━━━━━━━━━━━━━━━━━━━━━━

📌 CHAPTERS
━━━━━━━━━━━━━━━━━━━━━━━━
0:00 The 0.1 + 0.2 Problem
1:01 Fixed-Point Arithmetic
5:57 Scientific Notation & the Birth of Floating Point
6:48 The IEEE 754 Standard
7:01 Converting 3.14 to a 32-bit Float
11:12 Proving it in C
13:24 Edge Cases: Infinity and NaN
15:20 Why IEEE 754 Changed Everything

━━━━━━━━━━━━━━━━━━━━━━━━

🔗 LINKS & RESOURCES
━━━━━━━━━━━━━━━━━━━━━━━━
☕ Support the channel on Patreon (+ 24hr early access, no ads):
https://www.patreon.com/ncot_tech
Scientific Calculator - Thirunavukkarasye-Raveendran, CC BY 4.0 https://creativecommons.org/licenses/by/4.0, via Wikimedia Commons
Intel 486 DX2 Die shot - This file was derived from: Intel 80486 DX2 die.JPG by Pauli Rautakorpi CC BY 3.0
Music by Karl Casey @ White Bat Audio

...more
View all episodesView all episodes
Download on the App Store

PeerTube de WeKeysBy