Re:Floating-Point Printing and Parsing Can Be Simple and Fast
by nigeltao on Friday January 23, 2026 @07:07PM
(#46739648)
> Russ Cox should make a C version of his code.
Re:Floating-Point Printing and Parsing Can Be Simple and Fast
by vitaut on Friday January 23, 2026 @10:18PM
(#46740732)
Note that it has the same table of powers of 10: https://github.com/rsc/fpfmt/blob/main/bench/uscalec/pow10.h
Re:Floating-Point Printing and Parsing Can Be Simple and Fast
by vitaut on Friday January 23, 2026 @10:20PM
(#46740744)
It is possible to compress the table using the technique from Dragonbox (https://github.com/fmtlib/fmt/blob/8b8fccdad40decf68687ec038...) at the cost of some perf. It's on my TODO list for zmij.
Re:Floating-Point Printing and Parsing Can Be Simple and Fast
by thomasmg on Sunday January 25, 2026 @12:08PM
(#46755825)
Schubfach, Ryū, Dragonbox etc support round-tripping and shortest-width, which (it sounds like) is not important for you. The idea of round-tripping is that if you convert a double to a string and then parse that, you get the exact same value. Shortest-width is to correctly round and generate the shortest possible text. I tried to implement a version that does _just_ round-tripping but is not shortest-width, it is around 290 lines for both parsing and toString [1]
[1] https://github.com/thomasmueller/bau-lang/blob/main/src/test...
https://github.com/nklabs/libnklabs/blob/main/src/nkprintf_f... https://github.com/nklabs/libnklabs/blob/main/src/nkstrtod.c https://github.com/nklabs/libnklabs/blob/main/src/nkdectab.c
nkprintf_fp.c+nkdectab.c: 2494 bytes
schubfach.cc: 10K bytes.. the code is small, but there is a giant table of numbers. Also this is just dtoa, not a full printf formatter.
OTOH, the old code is not round-trip accurate.
Russ Cox should make a C version of his code..