Re: Greatest Common Divisor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>
Cc: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Stephen Frost <sfrost(at)snowman(dot)net>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Greatest Common Divisor
Date: 2020-01-04 00:21:17
Message-ID: 15229.1578097277@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com> writes:
> On 03/01/2020 20:14, Fabien COELHO wrote:
>> I'm unsure about gcd(INT_MIN, 0) should error. Possibly 0 would be nicer?

> What justification for that do you have?

Zero is the "correct" answer for that, isn't it, independently of overflow
considerations? We should strive to give the correct answer if it's known
and representable, rather than have arbitrary failure conditions.

(IOW, we should throw errors only when the *result* is out of range
or undefined, not just because the input is an edge case.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2020-01-04 00:21:32 Re: Greatest Common Divisor
Previous Message Mikael Kjellström 2020-01-04 00:21:13 Re: sidewinder has one failure