## digitalmars.D - Boost licensed implementation of Fabian Loitsch's Grisu-algorithm

- Andre Pany (8/8) Jan 04 Hi,
- kdevel (17/20) Jan 04 "[...] we propose a variant, Grisu3, that detects (and
- Andre Pany (8/30) Jan 04 My understanding is that std.conv: to isn't available at compile
- Basile B. (10/27) Jan 05 It's not only about speed. It's also about being consistent
- Stefan Koch (4/12) Jan 04 We could ... I ported it a few days ago :)
- Andre Pany (5/21) Jan 04 You did a great work. The missing piece was the MIT license. In
- Andre Pany (6/22) Jan 06 Do you plan to create a pull request for druntime to add your
- Stefan Koch (5/30) Jan 06 I wanted to polish it a little before proposing the inclusion.
- Andre Pany (4/10) Jan 06 Fantastic, thanks a lot!
- Andrei Alexandrescu (2/14) Jan 04 That would be gladly considered!
- tipdbmp (4/4) Jan 05 Have you considered Ulf Adams' Ryu float-to-string algorithm that
- Stefan Koch (4/8) Jan 05 So does grisu.

Hi, This implementation of Fabian Loitsch's Grisu-algorithm is now boost licensed. https://github.com/night-shift/fpconv Can we add it to druntime/phobos for Compile time float to string conversion? Kind regards Andre

Jan 04

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

Jan 04

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: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 AndreThis 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

Jan 04

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: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#c6This 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?

Jan 05

On Friday, 4 January 2019 at 17:41:19 UTC, Andre Pany wrote:Hi, This implementation of Fabian Loitsch's Grisu-algorithm is now boost licensed. https://github.com/night-shift/fpconv Can we add it to druntime/phobos for Compile time float to string conversion? Kind regards AndreWe could ... I ported it a few days ago :) https://github.com/UplinkCoder/fpconv But I'd like it to go into druntime rather than phobos.

Jan 04

On Friday, 4 January 2019 at 19:43:19 UTC, Stefan Koch wrote:On Friday, 4 January 2019 at 17:41:19 UTC, Andre Pany wrote:You did a great work. The missing piece was the MIT license. In the meantime the license was changed;) Kind regards AndreHi, This implementation of Fabian Loitsch's Grisu-algorithm is now boost licensed. https://github.com/night-shift/fpconv Can we add it to druntime/phobos for Compile time float to string conversion? Kind regards AndreWe could ... I ported it a few days ago :) https://github.com/UplinkCoder/fpconv But I'd like it to go into druntime rather than phobos.

Jan 04

On Friday, 4 January 2019 at 19:43:19 UTC, Stefan Koch wrote:On Friday, 4 January 2019 at 17:41:19 UTC, Andre Pany wrote:Do you plan to create a pull request for druntime to add your port (independent from new ctfe engine)? If not, would you mind if I create an issue to get it merged? Kind regards Andre

Jan 06

On Sunday, 6 January 2019 at 09:41:30 UTC, Andre Pany wrote:On Friday, 4 January 2019 at 19:43:19 UTC, Stefan Koch wrote:I wanted to polish it a little before proposing the inclusion. I'll send a PR shortly. Regards, Stefan

Jan 06

On Sunday, 6 January 2019 at 17:10:15 UTC, Stefan Koch wrote:On Sunday, 6 January 2019 at 09:41:30 UTC, Andre Pany wrote:Fantastic, thanks a lot! Kind regards AndreOn Friday, 4 January 2019 at 19:43:19 UTC, Stefan Koch wrote:I wanted to polish it a little before proposing the inclusion. I'll send a PR shortly. Regards, Stefan

Jan 06

On 1/4/19 12:41 PM, Andre Pany wrote:

Jan 04

Have you considered Ulf Adams' Ryu float-to-string algorithm that uses only fixed-size integer operations? https://dl.acm.org/citation.cfm?id=3192369 https://github.com/ulfjack/ryu

Jan 05

On Saturday, 5 January 2019 at 12:34:44 UTC, tipdbmp wrote:Have you considered Ulf Adams' Ryu float-to-string algorithm that uses only fixed-size integer operations? https://dl.acm.org/citation.cfm?id=3192369 https://github.com/ulfjack/ryuSo does grisu. ryu is a minor improvement of grisu2. Just the paper is much more confusing then the grisu2 one is.

Jan 05