Converting Binary Floating-Point Numbers to Shortest Decimal Strings

onlinelibrary.wiley.com

18 points by matt_d 4 days ago


boisterousness - 3 hours ago

Another contender: Russ Cox's "fast unrounded scaling" [1].

Cox writes: "The main idea of this post is to implement fast unrounded scaling, which computes an approximation to x · 2^e · 10^p, often in a single 64-bit multiplication. On that foundation we can build nearly trivial printing and parsing algorithms that run very fast. In fact, the printing algorithms run faster than all other known algorithms, including Dragon4, Grisu3, Errol3, Ryū, Ryū Printf, Schubfach, and Dragonbox, and the parsing algorithm runs faster than the Eisel-Lemire algorithm. This post presents both the algorithms and a concrete implementation in Go. I expect some form of this Go code to ship in Go 1.27 (scheduled for August 2026)."

[1] https://research.swtch.com/fp

leni536 - 13 hours ago

zmij[1] is claimed to be significantly faster than all of the tested implementations in the paper. It would have been nice if it was included.

[1] https://github.com/vitaut/zmij