Printing floating point numbers is surprisingly hard!!
summary
Claim: converting binary floats to the shortest decimal that round-trips is subtle and many languages lack guarantees. The landscape is concrete: Dragon4 is correct but slow, Grisu3 is ~12.5× faster yet fails on a few percent and needs a Dragon4 fallback, and Ryu (2018) cuts work dramatically (roughly 3–5× faster than Grisu3 on tricky cases) while provably producing the shortest round-trippable decimal. The talk demos algorithms, shows the surprising failure counts, and compares performance and fallbacks.
AI-written summary · about
chapters (6)
- 0:00Floating point printing issues
- 1:16Decimal fractions in binary
- 3:02Correctness in printing algorithms
- 6:23Dragon4 and Grisu3 explained
- 9:02Ryu algorithm and solutions
- 10:52Challenges in printing floats
related talks
14mPrinting Floating Numbers is Surprisingly Hard!
01h 41mFast Conversion From Cpp Floating Point Numbers
01mTalk Preview: A new dragon in the den: fast conversion from floating-point numbers
57mFloating-Point to String Conversion in C++: Exploring Algorithms & Performance
58mPortable floating-point calculations
26mGenerating Correctly Rounded Math Libraries for New Floating Point Variants
01h 00mFloating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss
22mOne Polynomial Approximation to Produce Correctly Rounded Results of an Elementa
