Floating-Point to String Conversion in C++: Exploring Algorithms & Performance
summary
Introduces a new TJaguar (Jaguar) algorithm that converts IEEE‑754 floats to decimal by decoding sign/exponent/mantissa, using precomputed power‑of‑two lookup tables and integer-only arithmetic to pick the optimal decimal exponent F, apply round‑to‑even tie breaks, strip trailing zeros and emit the shortest round‑trip string. An implementation is benchmarked on centered doubles: Jaguar is faster than Dragonbox on ~99.5% of samples and shows roughly a ~27% average speedup vs Dragonbox, with both beating older Ryu/Grisu approaches.
AI-written summary · about
chapters (13)
- 0:00Hydra problem in float conversion
- 2:11Why float to string matters
- 5:03How floats are stored
- 12:56IEEE 754 binary representations
- 19:05Why 1/3 prints as 0.33333334
- 22:41Dragon algorithms for conversion
- 24:07Dragon’s problem explained
- 34:10Jaguar algorithm origin
- 37:02Jaguar algorithm step-by-step
- 48:35Simplifying Jaguar performance
- 51:26Jaguar optimizations
- 54:18Benchmark Jaguar vs Dragon Box vs Grisu
- 56:25Jaguar algorithm revealed
related talks
01h 41mFast Conversion From Cpp Floating Point Numbers
11mPrinting floating point numbers is surprisingly hard!!
14mPrinting Floating Numbers is Surprisingly Hard!
58mPortable floating-point calculations
01h 00mFloating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss
14mFloat Self-Tagging
26mGenerating Correctly Rounded Math Libraries for New Floating Point Variants
36mSelf-Tagging Numbers
