Re: Greatest Common Divisor

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: Greatest Common Divisor
Дата
Msg-id alpine.DEB.2.21.2001040925230.31333@pseudo
обсуждение исходный текст
Ответ на Re: Greatest Common Divisor  (Vik Fearing <vik.fearing@2ndquadrant.com>)
Ответы Re: Greatest Common Divisor
Список pgsql-hackers
Bonjour Vik,

>> The point of swapping is to a void possibly expensive modulo, but this
>> should be done on absolute values, otherwise it may not achieve its
>> purpose as stated by the comment?
>
> Ah, true.  How widespread are these architectures that need this special
> treatment?  Is it really worth handling?

Dunno. AFAICR it was with sparc architectures 25 years ago.

Also I do not like much relying on the subtleties of C99 % wrt negative 
numbers to have the algorithm work, I'd be much at ease to deal with sign 
and special values at the beginning of the function and proceed with 
positive numbers afterwards.

>> I'm unsure about gcd(INT_MIN, 0) should error. Possibly 0 would be nicer?
>
>
> What justification for that do you have?

ISTM that the current implementation has:

   \forall int4 n, n \neq MIN_INT4, \gcd(n, 0) = 0 ?

In which case applying the same rule for min int seems ok.

-- 
Fabien Coelho - CRI, MINES ParisTech

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: Greatest Common Divisor