Re: Slaying the HYPOTamus - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Slaying the HYPOTamus
Date
Msg-id 407d949e0908222139t35ad3ad2q3e6b15646a27dd64@mail.gmail.com
Whole thread Raw
In response to Slaying the HYPOTamus  (Paul Matthews <plm@netspace.net.au>)
Responses Re: Slaying the HYPOTamus  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sun, Aug 23, 2009 at 4:54 AM, Paul Matthews<plm@netspace.net.au> wrote:
>
> The hypot() function has been part of the C standard since C99 (ie 10
> years ago)

Postgres targets C89. The date of the standard is when the standard
came out, it takes years before it's widely available and then years
again before the systems with the old compiler are no longer
interesting.

If there's a performance advantage then we could add a configure test
and define the macro to call hypot(). You said it existed before C99
though, how widespread was it? If it's in all the platforms we support
it might be reasonable to just go with it.

> The function is designed not to fail where the current naive macro would
> result in overflow.

The code seems to be blissfully unaware of overflow dangers :( Even if
hypot() avoids spurious overflows it's always possible for there to be
a legitimate overflow which we ought to detect and handle properly.

-- 
greg
http://mit.edu/~gsstark/resume.pdf


pgsql-hackers by date:

Previous
From: Paul Matthews
Date:
Subject: Slaying the HYPOTamus
Next
From: Tom Lane
Date:
Subject: Re: Slaying the HYPOTamus