These macros are from geo_decls.h:
#define EPSILON					1.0E-06

#ifdef EPSILON
#define FPzero(A)				(fabs(A) <= EPSILON)
#define FPeq(A,B)				(fabs((A) - (B)) <=
EPSILON)
#define FPne(A,B)				(fabs((A) - (B)) >
EPSILON)
#define FPlt(A,B)				((B) - (A) > EPSILON)
#define FPle(A,B)				((A) - (B) <= EPSILON)
#define FPgt(A,B)				((A) - (B) > EPSILON)
#define FPge(A,B)				((B) - (A) <= EPSILON)
#else
#define FPzero(A)				((A) == 0)
#define FPeq(A,B)				((A) == (B))
#define FPne(A,B)				((A) != (B))
#define FPlt(A,B)				((A) < (B))
#define FPle(A,B)				((A) <= (B))
#define FPgt(A,B)				((A) > (B))
#define FPge(A,B)				((A) >= (B))
#endif

But to compare floating point, those are simply wrong.  If the values
are both very small or both very large, the method fails.
Here is a more reliable way to make a comparison:

#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;
}

All the macros can then be defined in terms of the comparison function.
It's not perfect either, but at least it is better.

Wed, 13 Feb 2002 16:26:34 -0800
"Dann Corbit" <DCorbit@connx.com>
geo_decls.h oopsie...
"Dann Corbit" <DCorbit@connx.com> writes:
> But to compare floating point, those are simply wrong.

See previous discussions concerning the quality of the builtin geometric
types.  Not clear that it's worth worrying about, unless you want to go
in for a wholesale overhaul.  My own opinion is that PostGIS will
supersede the need for these types...

> Here is a more reliable way to make a comparison:

Not like that.  Perhaps use a fraction of the absolute value of the
one with larger absolute value.  As-is it's hard to tell how FLT_EPSILON
is measured.

			regards, tom lane

Wed, 13 Feb 2002 20:07:48 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: geo_decls.h oopsie... 
> > But to compare floating point, those are simply wrong.
> See previous discussions concerning the quality of the builtin geometric
> types.  Not clear that it's worth worrying about, unless you want to go
> in for a wholesale overhaul.  My own opinion is that PostGIS will
> supersede the need for these types...

Oops. I think that we will welcome any updates and fixes to any of the
built in features of PostgreSQL, no matter our individual opinions of
the usefulness of a particular feature (right??). In this case, the
return value patches would seem to be important and the second topic
should be addressed also.

                     - Thomas

Thu, 14 Feb 2002 12:21:59 -0800
Thomas Lockhart <lockhart@fourpalms.org>
Re: geo_decls.h oopsie...