Boost licensed implementation of Fabian Loitsch's Grisu-algorithm

Andre Pany andre at s-e-a-p.de
Fri Jan 4 19:48:51 UTC 2019


On Friday, 4 January 2019 at 19:38:36 UTC, kdevel wrote:
> On Friday, 4 January 2019 at 17:41:19 UTC, Andre Pany wrote:
>> This implementation of Fabian Loitsch's Grisu-algorithm
>
> "[...] we propose a variant, Grisu3, that detects (and
> aborts) when its output may not be the shortest. As a 
> consequence
> Grisu3 is incomplete and will fail for some percentage of its 
> input.
> Given 11 extra bits roughly 99.5% are processed correctly and
> are thus guaranteed to be optimal (with respect to shortness and
> rounding). The remaining 0.5% are rejected and need to be 
> printed
> by another printing algorithm (like Dragon4)." [1]
>
> [...]
>
>> Can we add it to druntime/phobos for
>> Compile time float to string conversion?
>
> What kind of source code could benefit from speeding up this 
> conversion?
>
> [1] Florian Loitsch: Printing Floating-Point Numbers Quickly 
> and Accurately
>     with Integers. In Proceedings of the 2010 ACM SIGPLAN
>     Conference on Programming Language Design and 
> Implementation, PLDI 2010

My understanding is that std.conv: to isn't available at compile 
time because of the missing float to string implementation.

In another thread ketmar mentioned that with a D implementation 
the formatting will be consistent for all platforms.
https://forum.dlang.org/post/22429a6afdfd4633bf5723a12dd2917d@chiroptera

Kind regards
Andre



More information about the Digitalmars-d mailing list