Printing floating points
deadalnix
deadalnix at gmail.com
Fri Jan 22 21:37:08 UTC 2021
On Friday, 22 January 2021 at 18:01:41 UTC, Paul Backus wrote:
> On Friday, 22 January 2021 at 16:42:20 UTC, Imperatorn wrote:
>>
>> Interesting, doesn't seem to be ryu though
>
> From the linked PDF [1]:
>
>> Ryu and other fast algorithms have been rejected, because they
>> cannot be used for printf-like functions due to a different
>> design goal.
>
> According to the Ryu README on Github [2], "Ryu generates the
> shortest decimal representation of a floating point number that
> maintains round-trip safety." For printf, the user is allowed
> to specify things like the precision, the field width, and
> whether leading zeros should be used for padding, so a more
> flexible algorithm is needed.
>
> [1]
> https://raw.githubusercontent.com/berni44/printFloat/master/printFloat.pdf
> [2] https://github.com/ulfjack/ryu
People have been suing variation of this for printf. But yes, it
is not suffisient by itself.
More information about the Digitalmars-d
mailing list