> A couple of comments on dealing with floats.
>
> - Use FLT_EPSILON/DBL_EPSILON from float.h
>
> - You method is total overkill, return (fabs(x - y) < DBL_EPSILON ? 1 : 0);
>   should be sufficent (note: check with a numerical expert).

This is what I thought in the beginning.  However, whether one uses
FLT_EPSILON or DBL_EPSILON depends upon the type of the numbers used
(float or double), so there wasn't a nice general solution.  Anyway, I
thought it best to ask on list before I started implementing stuff.
:-)

> - What about NANs and INFs?  I typical test for one of the values being
>   NAN but allow INFs to be compared.

Andy Lester's post mentioned that we're only comparing against zero in
each instance so we don't really need the general solution and so
shouldn't need to worry about this case.

Paul

Reply via email to