“Floating-Point Printing and Parsing Can Be Simple And Fast”

The fastest known floating-point printer and parsing algorithms - fixed-width printing, shortest-width printing, and parsing, all in 400 lines of Go.

https://research.swtch.com/fp
https://research.swtch.com/fp-proof

research!rsc: Floating-Point Printing and Parsing Can Be Simple And Fast (Floating Point Formatting, Part 3)

@rsc have you seen https://vitaut.net/posts/2025/smallest-dtoa/ / https://vitaut.net/posts/2025/faster-dtoa/ / https://github.com/vitaut/zmij ? It's also pretty short and fast, and I didn't see it mentioned in your references section. (I haven't read your post in detail yet, apologies if it's mentioned somewhere!)

Also, the #perf link doesn't seem to work for me.

The smallest state-of-the-art double-to-string implementation

@thakis @rsc BTW zmij is already using a single multiplication by a power of 10 in the common case based on the work by Yaoyuan Guo. However, it looks like with this we can get rid of the fallback (Schubfach) which might simplify the implementation a bit.
@thakis @rsc Also unrounded logic seems similar to what Schubfach does - multiplication by 4 and sticky rounding (modified round to odd + shift). I am surprised it is not called out in the article. Maybe I missed something.
@vitaut @thakis Yes indeed. There's a paragraph about that in https://research.swtch.com/fp#related.short.
research!rsc: Floating-Point Printing and Parsing Can Be Simple And Fast (Floating Point Formatting, Part 3)

@rsc @thakis Thanks! I missed this section when reading last night but figured what’s going on on my own =)