Messing with Floating Point
summary
Walks through IEEE 754 bit layout and shows concrete C++ tools and results: using numeric_limits, nextafter, fe exception APIs and the floating‑point environment, a custom ULP distance (cast to unsigned int), and hexadecimal float literals for exact values. Demonstrates printing 0.1 shows a ~1.5e‑9 representation delta, explains the Patriot missile 500m miss from accumulated 0.1 error, proves Kahan summation fixes a 100M‑random‑float sum where naive summing fails, and sketches float‑to‑decimal and fast inverse square root* algorithms.
AI-written summary · about
chapters (16)
- 0:00Introduction to floating point
- 1:09Floating point basics
- 7:52Common floating point pitfalls
- 17:05Underflow and denormal numbers
- 20:16Floating point comparisons
- 23:28Resolution error in addition
- 30:15Minecraft floating point quirks
- 33:30IEEE 754 standard overview
- 38:25Exceptional values in IEEE 754
- 40:52Floating point exceptions
- 44:21Rounding modes explained
- 45:45Arithmetic guarantees of IEEE 754
- 52:33Bonus: Float to decimal algorithm
- 55:22Bonus: Fast inverse square root
- 56:25Hexadecimal float literals
- 57:52Q&A session
