Re: Fixing geometic calculation

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fixing geometic calculation
Date: 2009-08-07 16:30:03
Message-ID: 20090807163003.GL5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 07, 2009 at 11:40:58AM -0400, Tom Lane wrote:
> Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> > I would agree with Paul that EPSILON is a hack and probably should be
> > removed.
>
> It's a hack but it's dealing with an extremely real problem, namely
> the built-in inaccuracy of floating-point arithmetic. You can't just
> close your eyes to that and hope that everything will be okay.

Yes, I know it's a fiddle to get right. Choosing the right primitives
is generally the most difficult part.

> A quick look through the geometry sources says that we might not be
> critically dependent on anything except the assumption that two values
> that aren't FPeq() will have a nonzero difference.

Sorry, I'm struggling to parse that. I think it's all the double
negatives. Are you saying that HYPOT() should really return zero when
it's currently giving back would be FPzero?

> (If you think this
> is a tautology, you don't know enough about floating point arithmetic
> to be qualified to offer an opinion here...)

I think I have a reasonable idea about FP arithmetic, I have had to
worry about rounding modes and such like before. Never tried to write a
FP emulator though so I'm sure I could know more.

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-08-07 16:35:40 Re: \copy: unexpected response (4)
Previous Message Alex Hunsaker 2009-08-07 16:23:27 Re: slow commits with heavy temp table usage in 8.4.0