(no title)
vitaut
|
1 month ago
The shortest double-to-string algorithm is basically Schubfach or, rather, it's variation Tejú Jaguá with digit output from Dragonbox. Schubfach is a beautiful algorithm: I implemented and wrote about it in https://vitaut.net/posts/2025/smallest-dtoa/. However, in terms of performance you can do much better nowadays. For example, https://github.com/vitaut/zmij does 1 instead of 2-3 costly 128x64-bit multiplications in the common case and has much more efficient digit output.
jhallenworld|1 month ago
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..
nigeltao|1 month ago
https://github.com/rsc/fpfmt/blob/main/bench/uscalec/ftoa.c
thomasmg|1 month ago
[1] https://github.com/thomasmueller/bau-lang/blob/main/src/test...
vitaut|1 month ago
andrepd|1 month ago
vitaut|1 month ago
magicalhippo|1 month ago
vitaut|1 month ago