I also posted this below as a reply.<p>Python uses David Gay&#x27;s algorithm for printing the shortest equivalent floating point representation.<p>Implementation details and discussion are available from the Python bug tracker:
<a href="https:&#x2F;&#x2F;bugs.python.org&#x2F;issue1580" rel="nofollow">https:&#x2F;&#x2F;bugs.python.org&#x2F;issue1580</a><p>There are a few broken links. I believe the original poster references the following paper by Robert Burger &amp; Kent Dybvig, &quot;Printing Floating-Point Numbers Quickly and Accurately&quot;:<p><a href="http:&#x2F;&#x2F;www.cs.indiana.edu&#x2F;~dyb&#x2F;pubs&#x2F;FP-Printing-PLDI96.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cs.indiana.edu&#x2F;~dyb&#x2F;pubs&#x2F;FP-Printing-PLDI96.pdf</a><p>There&#x27;s also a reference to the following paper by William Clinger, &quot;How to Read Floating Point Numbers Accurately&quot;:<p><a href="http:&#x2F;&#x2F;www.cesura17.net&#x2F;~will&#x2F;professional&#x2F;research&#x2F;papers&#x2F;retrospective.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cesura17.net&#x2F;~will&#x2F;professional&#x2F;research&#x2F;papers&#x2F;r...</a><p>ftp:&#x2F;&#x2F;ftp.ccs.neu.edu&#x2F;pub&#x2F;people&#x2F;will&#x2F;retrospective.pdf<p>I believe this is the David Gay paper, &quot;Correctly Rounded Binary-Decimal and Decimal-Binary Conversions&quot;:<p><a href="http:&#x2F;&#x2F;www.ampl.com&#x2F;REFS&#x2F;rounding.pdf" rel="nofollow">http:&#x2F;&#x2F;www.ampl.com&#x2F;REFS&#x2F;rounding.pdf</a><p>By the way, this has previously been discussed on HN (which is where I think I first read all of this...):<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=2708983" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=2708983</a>