printf() metaprogramming challenge

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sat May 25 08:42:57 UTC 2019


On Friday, 24 May 2019 at 22:59:10 UTC, Walter Bright wrote:
> https://github.com/ulfjack/ryu says: "The Java implementation 
> differs from the output of Double.toString in some cases: 
> sometimes the output is shorter (which is arguably more 
> accurate) and sometimes the output may differ in the precise 
> digits output" which I find fairly concerning. Please review 
> the paper I linked to in my reply to Jacob.

FWIW the Ryu algorithm looks like a serious piece of work — see 
this paper, which references (and compares in detail) to the 
paper you linked to:
https://dl.acm.org/citation.cfm?id=3192369

It covers in some detail the rationale for the differences you 
note.

> Floating point formatting is not something that can be knocked 
> out in an hour. You can get a "mostly working" implementation 
> that way, but not a serious, robust, correct implementation 
> with the expected flexibility. (And the test cases to prove it 
> correct.)

One interesting remark in the paper on the Ryu algorithm: "We did 
not compare our implementation against the C standard library 
function printf, as its specification does not include the 
correctness criteria set forth by Steele and White [15], and, 
accordingly, neither the glibc nor the MacOS implementation does."


More information about the Digitalmars-d mailing list