Eric Blake <[EMAIL PROTECTED]> 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 ;-)


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to