develooper Front page | perl.perl5.porters | Postings from June 2021

Re: Creating an RFC process for Perl

Thread Previous | Thread Next
June 9, 2021 11:05
Re: Creating an RFC process for Perl
Message ID:
I think it's high time that perl's print() function embraced dragon4-type
[1] formatting of floating point values.
Admittedly, I won't be surprised if this never happens, but I do think it
should formally be placed on the TODO list ... and then ... who knows ...

Given that I probably won't ever be in a position to provide a PR that
implements this, should I therefore refrain from making such an RFC ?


[1] It doesn't have to be dragon4  - it could be grisu3 or ryu. However, it
has to be something that would work with all 3 of perl's nvtypes, and I'm
not sure that grisu3 or ryu will scale to "long double" and "__float128"
You, Nicholas, might have a better knowledge of that.
I should add that I've never written an implementation of dragon4 - mainly
because I haven't yet managed to come to grips with that procedure, as
presented in tables 5 to 13 of  "How to Print FloatingPoint Numbers
Accurately" by Steele and White.
However, in my Math::MPFR module, I have implemented tables 3 and 4 (from
the same Steele and White paper) such that the desired dragon4-type
presentation of these values is provided for all 3 nvtypes, including the
"DoubleDouble" long double nvtype.
This implementation (which I've called "nvtoa") uses the gmp library to
handle the arbitrary precision integer arithmetic. If the nvtype is
"DoubleDouble",  nvtoa() also requires the mpfr library.
It's about 3 to 4 times more costly (in time) than perl's sprintf(), but it
works reliably AFAIK.
Math::MPFR also provides dragon4-type presentation of arbitrary precision
floating point values via the "mpfrtoa" function.
And ... there's more ... Math::MPFR additionally provides a grisu3
implementation (named "doubletoa") - but that's just a copy'n'paste of
grisu3, and applies only to nvtype of 'double'.
Isuspect that talented and gifted programmers might see my implementations
as being rather pedestrian ... but, AFAIK, that's all we currently have wrt

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About