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

Vincent Lefevre vincent@vinc17.net
Wed Jan 8 11:15:39 GMT 2025


> > At the time, I thought I was getting decimal (exact) arithmetic.
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that decimal arithmetic and exact arithmetic are two different
things.

> > I didn't understand that it was still floating point, which, even
> > though the precision could be extended, still isn't exact.
> 
> Sorry, do you mean decimal floating point support, as in Java's
> BigDecimal?  I can see how this is very useful for some applications.

AFAIK, Java's BigDecimal is still floating-point arithmetic, but
in decimal. It will not be exact, except for some particular
computations.

Exact arithmetic (as provided by computer algebra systems) is much
more complex, with many practical limitations. An alternative may
be something like iRRAM (but this will not solve issues due to
discontinuous functions).

> If I read the documentation correctly, MPFR only provides binary
> floating point support.

Yes, MPFR only provides binary floating-point arithmetic if you
want correct rounding. If you do not care about correct rounding,
the base does not really matter (but I suppose that binary would
be faster than decimal).

In the gawk ChangeLog.1 file, I can read:

2012-04-02         John Haque      <j.eh@mchsi.com>

        Add support for arbitrary-precision arithmetic.

        * mpfr.c: New file.
[...]

So, it seems that the use of MPFR was for arbitrary-precision
arithmetic, not for decimal arithmetic.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Libc-alpha mailing list