bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Stale cache of MPFR formatted+rounded strings


From: arnold
Subject: Re: [bug-gawk] Stale cache of MPFR formatted+rounded strings
Date: Sun, 31 Dec 2017 05:05:18 -0700
User-agent: Heirloom mailx 12.4 7/29/08

Thanks for the report.  The dev team will think about this.

Thanks,

Arnold

Nethox <address@hidden> wrote:

> Compiled from the tarball on GNU/Linux x86:
> $ gawk -V | head -1
> GNU Awk 4.2.0, API: 2.0 (GNU MPFR 3.1.5, GNU MP 6.1.2)
>
> Minimal reproducible test:
> $ cat mpfrrndeval.min.awk
> BEGIN {
>         pi = 3.1416
>         OFMT = "%.f"
>         print pi  # ROUNDMODE = "N" by default.
>         ROUNDMODE = "U"
>         print pi
> }
> $ gawk -M -f ./mpfrrndeval.min.awk
> 3
> 3
> $ cat mpfrrndeval.min.ok
> 3
> 4
>
> GAWK seems to cache the MPFR formatted+rounded string for each variable
> printed with OFMT or CONVFMT (not printf). However, this cache is not
> discarded when ROUNDMODE is assigned to a different mode, so only the first
> printing is correct for certain.
> Workarounds: reassigning pi=3.1416 or pi=pi+0 before every print
> evaluation; reassigning OFMT/CONVFMT to a different precision before every
> print evaluation; replacing each print lvalue argument with rvalues like
> the literal 3.1416 or pi+0.
> Useless things: --lint, --no-optimize.
>
> I attach a more complete test and results (filenames without .min).
>
> Regards.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]