TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Printing Floating-Point Numbers (2014)

21 pointsby cronjobberover 9 years ago

4 comments

specialistover 9 years ago
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:&#x2F;&#x2F;www.clarusft.com&#x2F;dragon4-and-grisu3-algorithms-to-display-floating-point-numbers&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.clarusft.com&#x2F;dragon4-and-grisu3-algorithms-to-di...</a><p>&quot;Printing Floating-Point Numbers Quickly and Accurately with Integers&quot; by Florian Loitsch<p><a href="http:&#x2F;&#x2F;www.cs.tufts.edu&#x2F;~nr&#x2F;cs257&#x2F;archive&#x2F;florian-loitsch&#x2F;printf.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cs.tufts.edu&#x2F;~nr&#x2F;cs257&#x2F;archive&#x2F;florian-loitsch&#x2F;pr...</a><p>And its implementation in C<p><a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;double-conversion" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;double-conversion</a><p>Here&#x27;s a Java implementation of Grisu2 algorithm.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jnordwick&#x2F;zerog-grisu" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jnordwick&#x2F;zerog-grisu</a>
theohover 9 years ago
See also Russ Cox&#x27;s take on this: <a href="http:&#x2F;&#x2F;research.swtch.com&#x2F;ftoa" rel="nofollow">http:&#x2F;&#x2F;research.swtch.com&#x2F;ftoa</a>
jlaroccoover 9 years ago
&gt; Personally, I don&#x27;t use anything with an MIT or BSD style license because I&#x27;d rather avoid the legal baggage.<p>Gees, what a troll.
评论 #10568954 未加载
jhallenworldover 9 years ago
It reminds me that it&#x27;s annoying that there is no &quot;engineering&quot; mode for printf (to force the exponent to be a multiple of three). There is this project on github using %.*f: <a href="https:&#x2F;&#x2F;github.com&#x2F;dhoerl&#x2F;EngineeringNotationFormatter" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dhoerl&#x2F;EngineeringNotationFormatter</a>
评论 #10568760 未加载