r/cpp • u/aearphen {fmt} • Nov 29 '25
The smallest state-of-the-art double-to-string implementation (in C++)
https://vitaut.net/posts/2025/smallest-dtoa/
135
Upvotes
r/cpp • u/aearphen {fmt} • Nov 29 '25
71
u/STL MSVC STL Dev Nov 30 '25
As a reminder, because this article mentions Grisu2 with no caveats, it is not a correct algorithm if your requirement is shortest round-trip (as clearly explained by Loitsch's paper). The Grisu3 variant detects the cases where it's not shortest, but just rejects them, and you still need a complete algorithm to handle the remaining cases.
For this reason, I quickly ruled out Grisu2/3 when working on MSVC's charconv implementation.
14
u/jk-jeon Nov 30 '25
Nice write up, thanks! I think the industry will likely settle on a better algorithm than Dragonbox in the near future, and I'm pretty certain that any improvement over the current SOTA will be again essentially an optimized variant of Schubfach. Two core essence you listed will still be there.
I still think it's a bit unfortunate that Ryu got much more attention than Schubfach even though (IMO) Schubfach is not only faster but also simpler, and they even emerged almost simultaneously.
30
u/tartaruga232 MSVC user, r/cpp_modules Nov 29 '25
This uses the MIT license. Would be nice if this could instead be licensed under the boost license. Quote: