[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Error Gawk Manual FP Precision
From: |
Neil R. Ormos |
Subject: |
Re: [bug-gawk] Error Gawk Manual FP Precision |
Date: |
Mon, 20 Aug 2018 11:10:04 -0500 (CDT) |
address@hidden wrote:
|> function within_delta(a, b, delta)
|> {
|> if ((a > 0 && b > 0) || (a < 0 && b < 0))
|> return abs(a - b) <= abs(delta)
|> else
|> return (a - b) <= abs(delta)
|> }
The initial test seems more complex than
necessary, especially in a part of the manual that
is intended to be pedagogical. Would the
following be suitable?
function within_delta(a, b, delta)
{
if (a > b)
return (a - b) <= abs(delta)
else
return (b - a) <= abs(delta)
}
Best regards,
--Neil Ormos