Boost licensed implementation of Fabian Loitsch's Grisu-algorithm

Basile B. b2.temp at gmx.com
Sat Jan 5 16:30:27 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?

It's not only about speed. It's also about being consistent 
across platforms. Currently DMD for win32 uses an ancillary 
method that sometimes gives slightly different results than the 
other C libraries (see [1]). Then it's also about CTFE then only 
comes the speed criterion i think, as a bonus.

NB he admitted this himself [2].

[1]: 
https://github.com/DigitalMars/dmc/blob/9a774f3f2b3227fd416ec3a83cb9eb8f8751425f/src/core/strtold.c
[2]: https://issues.dlang.org/show_bug.cgi?id=5229#c6





More information about the Digitalmars-d mailing list