Re: Greatest Common Divisor
| От | Tom Lane |
|---|---|
| Тема | Re: Greatest Common Divisor |
| Дата | |
| Msg-id | 15876.1578098044@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Greatest Common Divisor (Vik Fearing <vik.fearing@2ndquadrant.com>) |
| Список | pgsql-hackers |
Vik Fearing <vik.fearing@2ndquadrant.com> writes:
> On 04/01/2020 01:21, Tom Lane wrote:
>> Zero is the "correct" answer for that, isn't it, independently of overflow
>> considerations?
> I would say not.
Oh, right, I was misremembering the identity gcd(a,0) as being 0 not a.
Never mind that then.
> The correct answer is INT_MIN but we've decided a
> negative result is not desirable.
Agreed. On the other hand, we could stave off overflow the same
way we discussed for lcm: make it return int8. We're still stuck
with the special case for INT64_MIN in gcd64 of course, so maybe
that's just inconsistent rather than being worthwhile.
[ thinks for a bit... ] In practice, I imagine few people use gcd on
negative values, so doing weird things with the datatype choices is
probably not better than throwing an error for this case.
regards, tom lane
В списке pgsql-hackers по дате отправления: