awk and stdio-common/tst-printf-format-as-double* trouble (mpfr support needed)

arnold@skeeve.com arnold@skeeve.com
Wed Jan 8 07:55:08 GMT 2025


Hi.

I've replied all, if anyone isn't interested then Maciej and I
can continue privately; let me know.

"Maciej W. Rozycki" <macro@redhat.com> wrote:

> Hi Arnold,
>
> > The longer story:
> > 
> > - Adding MPFR was a mistake. This became clear only in retrospect.
> >   But it's been there for so long I'm very hesitant to remove it.
>
> As a matter of interest would your please share the technical rationale 
> behind your conclusion?  The social factor, however regrettable, must only 
> have been secondary if any at all.

At the time, I thought I was getting decimal (exact) arithmetic. I didn't
understand that it was still floating point, which, even though the
precision could be extended, still isn't exact.

The technical points are:

1. No other awk supported MPFR, making gawk an outlier.

2. The maintainance overhead is VERY high. As I said, it took years upon
   years of work until all the paths through gawk behaved identically
   between regular f.p. and MPFR.

   And MPFR has it's fingers in the code in LOTS of places, not in just
   a few isolated parts of the code.

3. I don't think it gets used very much in the real world. Sure, some
   people use it, and report bugs and such, but it doesn't see the
   same use core awk features do.

> > - It took years until I could get identical results from the test suite
> >   for MPFR and non-MPFR (although I have that now).
>
> I do believe MPFR is still the only way to produce FP results beyond the 
> precision implemented by the host system.  I suppose it's also the way to 
> produce IEEE 754 results for non-IEEE FP hosts such as NetBSD/VAX.  Am I 
> missing anything here?

No, but that wasn't a motiviation.  MPFR was added by a developer on
my team (who later left in a huff, but that's another story). He did a lot
of good work, and I simply let him do MPFR also, since it seemed cool.
I was also quite busy with real life and $DAYJOB, so I didn't think
about it very hard.

It's only in hindsight that I understood that it was a mistake.

If you need high precision floating point, there are other places
to get it, such as Perl and Python.

> Of course none of that matters for the test cases concerned, they do not 
> require any extra precision, but only need a reference implementation that 
> is not the one under test.  This was my rationale to choose GAWK here, and 
> I do hope it wasn't a mistake of mine.

I think it's orthogonal. Gawk's printf uses the C library / MPFR for the
floating point results. So no benefit to you, there.

It does it's own printing for integer, character and string values.
For multiple precision integer values, it uses GMP / MPFR to get the
digits, and then it formats them further.

That's where your work really benefitted gawk; I ended up refactoring
the printf code considerably. It's now much better.

> Also I hope you share the GNU Project's principle of making free software 
> superior to any and all alternatives, and especially proprietary ones.  I 
> certainly do.  And from this point of view making use of MPFR, also a part 
> of the GNU Project, to circumvent hardware or OS limitations seems in line 
> with the spirit of the project.

That's all nice in retrospect. It wasn't an original motivation, at least
not for me.  

> > - A major asshole of a user who liked to use MPFR to show off how bright
> >   he was complained when things didn't meet his expectations and strongly
> >   insulted me, publicly.
>
> Sorry to hear about it and I realise that to conclude that it's that 
> person's problem does not cover you for the harm received.

Indeed. We banned him from the gawk lists, although he seems to have
subscribed to the help list under a different email. In any case, he's
been quiet since, for which I'm quite grateful.

> > - At that point I put MPFR on parole. It's not unmaintained though; one
> >   of my team has volunteered to help with bugs, although since then
> >   there haven't been any that I haven't been able to deal with.
>
> Thank you for taking care of that and for taking care of GAWK in the 
> first place.  It is a major effort and the GNU Project wouldn't survive 
> without people like you.

You're welcome.

> And last but not least, happy 2025!

Thanks, same to you.

I hope this note clarifies things somewhat.

Arnold


More information about the Libc-alpha mailing list