Probably a lot more sensible to change the interface to both functions
below to return int instead of double.
#include <float.h>
double double_compare(double d1, double d2)
{ if (d1 > d2) if ((d1 - d2) < fabs(d1 * DBL_EPSILON)) return 0; else return 1; if
(d1< d2) if ((d2 - d1) < fabs(d2 * DBL_EPSILON)) return 0; else return -1; return 0;
}
float float_compare(float d1, float d2)
{ if (d1 > d2) if ((d1 - d2) < fabs(d1 * FLT_EPSILON)) return 0; else return 1; if
(d1< d2) if ((d2 - d1) < fabs(d2 * FLT_EPSILON)) return 0; else return -1; return 0;
}