|
From: | david kerns |
Subject: | Re: [bug-gawk] Error Gawk Manual FP Precision |
Date: | Mon, 20 Aug 2018 09:00:20 -0700 |
On Mon, 20 Aug 2018 01:28:11 -0600, address@hidden wrote:
Hi Arnold,
> How does this look to you? I'm not sure it's right.
>
> Thanks,
>
> Arnold
The following simple version of the function within_delta should work:
function within_delta(a, b, delta)
{
return abs(a - b) < abs(delta) # note the '<'-sign
}
Weirdly, extending the test pairs in the script as is (with within_delta
from above) to
n = split("100.001 100.002 100.0001 100.0002 100 -100 100.0001
-100.0001", pairs)
gives a false positive for the first pair (given the 'strictly less than'
relation, 0.001 < 0.001 should yield 0).
Using GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1-p11, GNU MP 6.1.2).
Thanks,
J.
[Prev in Thread] | Current Thread | [Next in Thread] |