Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss
summary
C++17's charconv adds to_chars/from_chars for fast, locale-free conversion and uses Ulf Adams' Ryu and Ryu-printf variants to produce shortest round-trip decimals. MSVC implements full support after a year of work, ships large lookup tables, and avoids null terminators. Microbenchmarks show precision printing speedups of roughly 4–13× and a worst-case general double print dropping from ~2855 ns to ~206 ns; some shortest prints hit ~50 ns, so it reliably accelerates serialization.
AI-written summary · about
chapters (13)
- 0:00Start
- 0:14Introduction and speaker background
- 1:58Floating-point basics and representation
- 9:24Floating-point storage and IEEE 754
- 15:27Round-trip conversion and precision
- 21:28Introduction to <charconv>
- 27:29Using from_chars for parsing
- 33:09Using to_chars for formatting
- 41:17Algorithms behind <charconv> performance
- 48:44Performance benchmarks and speedups
- 55:05Implementation challenges and future work
- 58:35Memory usage and cache considerations
- 59:58Conclusion and Q&A
related talks
01mTalk Preview: A new dragon in the den: fast conversion from floating-point numbers
56mHow to Quickly Convert Floating-Point Numbers in C++
57mFloating-Point to String Conversion in C++: Exploring Algorithms & Performance
01h 05mFast and small C++ - When efficiency matters
11mPrinting floating point numbers is surprisingly hard!!
14mPrinting Floating Numbers is Surprisingly Hard!
58mPortable floating-point calculations
01h 01mMoving to C++20 for Fun, Beauty... and Results!
