bug-coreutils
[Top][All Lists]
Advanced

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

Re: Problems with coreutils-6.10.176-383b1.tar.gz


From: Jim Meyering
Subject: Re: Problems with coreutils-6.10.176-383b1.tar.gz
Date: Mon, 14 Apr 2008 21:17:13 +0200

Eric Blake <address@hidden> wrote:
> According to Jim Meyering on 4/14/2008 11:13 AM:
> |
> |           if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold)
> | -             && x_val == last)
> | +             && abs_rel_diff (x_val, last) < DBL_EPSILON)
>
> Don't you need to scale the result of abs_rel_diff to be on the same order
> of magnitude as x_val?  DBL_EPSILON represents 1 ulp of 1.0, but 2 ulps of
> 0.5.  It seems like what you are really trying to do here is terminate
> when the result is within 1 or 2 ulps, not when the result is less than
> DBL_EPSILON off.

The value returned by abs_rel_diff is already scaled,
so using DBL_EPSILON like that should be correct:

    /* Return the absolute relative difference from x to y.  */
    static double
    abs_rel_diff (double x, double y)
    {
      double s = (y == 0.0 ? 1 : y);
      return fabs ((y - x) / s);
    }

or maybe I'm being dense, in which case I'm sure someone
will correct me ;-)




reply via email to

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