Great links, thanks. I sometimes noodle with a faster printf for Java, mostly for giggles. I also found these:<p>Dragon4 and Grisu3: Algoritms to Display Floating Point Numbers<p><a href="https://www.clarusft.com/dragon4-and-grisu3-algorithms-to-display-floating-point-numbers/" rel="nofollow">https://www.clarusft.com/dragon4-and-grisu3-algorithms-to-di...</a><p>"Printing Floating-Point Numbers Quickly and Accurately with Integers" by Florian Loitsch<p><a href="http://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf" rel="nofollow">http://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/pr...</a><p>And its implementation in C<p><a href="https://github.com/google/double-conversion" rel="nofollow">https://github.com/google/double-conversion</a><p>Here's a Java implementation of Grisu2 algorithm.<p><a href="https://github.com/jnordwick/zerog-grisu" rel="nofollow">https://github.com/jnordwick/zerog-grisu</a>
See also Russ Cox's take on this:
<a href="http://research.swtch.com/ftoa" rel="nofollow">http://research.swtch.com/ftoa</a>
It reminds me that it's annoying that there is no "engineering" mode for printf (to force the exponent to be a multiple of three). There is this project on github using %.*f: <a href="https://github.com/dhoerl/EngineeringNotationFormatter" rel="nofollow">https://github.com/dhoerl/EngineeringNotationFormatter</a>