[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Error Gawk Manual FP Precision
From: |
arnold |
Subject: |
Re: [bug-gawk] Error Gawk Manual FP Precision |
Date: |
Fri, 24 Aug 2018 02:26:44 -0600 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Hi.
Thanks to all who have replied. I have updated the documentation
and will push it shortly.
Arnold
address@hidden wrote:
> Hi.
>
> Thanks for your note. In the future, PLEASE send in plain text
> format, not HTML, or at the very least, text and HTML.
>
> Thanks.
>
> On to your note:
>
> > Dear bug-gawk:
> >
> > The section on comparing two floating point values correctly recommends
> > making avoiding simple equality comparisons in favor of ensuring the
> > values are close enough.
> >
> > The code given in 15.4.1.2 "Be Careful Comparing Values" is clearly
> > wrong, though:
> >
> > The general wisdom when comparing floating-point values is to see
> > if they are within some small range of each other (called a delta,
> > or tolerance). You have to decide how small a delta is important
> > to you. Code to do this looks something like the following:
> >
> > delta = 0.00001???????????????? # for example
> > difference = abs(a) - abs(b)??? # subtract the two values
> > if (difference < delta)
> > ??? # all ok
> > else
> > ??? # not ok
> >
> > If the desired value, a is -1000, and b is +1000, the answer is off by
> > 2000. But difference will be zero.
>
> You are correct. I will look at revising the documentation.
>
> Thanks for pointing this out.
>
> Arnold
>