Re: Slaying the HYPOTamus

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Slaying the HYPOTamus
Дата
Msg-id 4A928BEE0200002500029FF2@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Slaying the HYPOTamus  (David Fetter <david@fetter.org>)
Ответы Re: Slaying the HYPOTamus  (David Fetter <david@fetter.org>)
Список pgsql-hackers
David Fetter <david@fetter.org> wrote: 
> On Mon, Aug 24, 2009 at 11:14:19PM +1000, Paul Matthews wrote:
> These next two lines are a teensy bit baroque.  Is there some
> significant speed increase that would justify them?
> 
>>     if (x == 0.0)
>>         return 0.0;
>>     else {
>>         yx = y/x;
>>         return x*sqrt(1.0+yx*yx);
>>     }
>> }
I think the reason is overflow.  From the function comment:
>>  * The traditional formulae of x^2+y^2 is rearranged
>>  * to bring x outside the sqrt. This allows computation of the
hypotenuse
>>  * for much larger magnitudes than otherwise normally possible.
Although I don't see why the first part isn't:   if (y == 0.0)       return x;
-Kevin


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: DELETE syntax on JOINS
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: 8.5 release timetable, again