bug-gawk
[Top][All Lists]
Advanced

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

Re: complie with mpfr support


From: Ivan Molineris
Subject: Re: complie with mpfr support
Date: Tue, 9 Feb 2021 16:45:19 +0100

Thanks Arnold,
I now understand that in modern linux distribution the gawk binary is
compiled by default with MPFR support, and all works well if -M is given.

In particular my version is
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)

And
$ echo 1.8e-308 | gawk -M '$1<0.05'
return "1.8e-308" as expected.

With the default PREC, what is the biggest number that will fail the above
test, even if in theory is lower than 0.05?

i.e.
$ echo <X> | gawk -M '$1<0.05'
do not return anything, even if <X> is smaller than 0.05


On Tue, Feb 9, 2021 at 4:30 PM <arnold@skeeve.com> wrote:

> Hi.
>
> First, understand that even when MPFR support is compiled in, gawk
> does not use it unless you invoke it with the -M option.
>
> Second, even with -M the default precision is 53 bits, the same as
> hardware floating-point doubles, so you have to set PREC to an appropriate
> value, typically with the -v option.
>
> What is the output of gawk --version from a default installation?
> That will tell you if your gawk is compiled with MPFR support or not.
>
> If not, then I suggest building the GMP and MPFR libraries and gawk
> itself from source and installing that copy in a place in $PATH where
> it will be found first.  It's really not that hard to so.
>
> Hope this helps,
>
> Arnold
>
> Ivan Molineris <ivan.molineris@gmail.com> wrote:
>
> > Indeed on Ubuntu gawk seems to be compiled with MPFR support.
> >
> > I would have thought that, when compiled with MPFR support, a command
> like
> > $ echo 1.8e-308 | gawk '$1<0.05'
> > will return "1.8e-308", but is not the case, it returns nothing.
> >
> > For me is not feasible to modify all my scripts to do something like
> > $ echo 1.8e-308 | gawk '$1+0<0.05'
> > as a workaround.
> >
> > Is there a better solution?
> >
> >
> > On Thu, Feb 4, 2021 at 8:55 PM <arnold@skeeve.com> wrote:
> >
> > > Ivan Molineris <ivan.molineris@gmail.com> wrote:
> > >
> > > > Hi all,
> > > > I would like to avoid problems like this one:
> > > >
> > >
> https://stackoverflow.com/questions/20684195/awk-and-numeric-comparison-with-number-less-than-1-7e-308
> > > >
> > > > If I understood well, if gawk is compiled with mpfr support,
> invoking it
> > > > with -M solve the problem.
> > > >
> > > > I tried to install mpfr whit
> > > > $ conda create -n gawk-compile -c conda-forge mpfr
> > > > and to configure ad compile gawk in this environment, but -M is
> still not
> > > > available.
> > > > How can I compile gawk with mpfr?
> > > >
> > > > Regards
> > >
> > > I have no idea what conda is or how it works.  I assume it's on some
> > > kind of Linux system?
> > >
> > > The simplest thing is to comple the GMP and MPFR libraries from
> > > source and install then and then compile gawk from source with the
> > > standard configure and make recipe.
> > >
> > > If you're on a Linux system with gawk already installed, maybe it was
> > > compiled with MPFR support already?  The output of gawk --version will
> > > show you the MPFR and GMP versions if so.
> > >
> > > HTH,
> > >
> > > Arnold
> > >
>


reply via email to

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