Re: Greatest Common Divisor

Dean Rasheed <dean.a.rasheed@gmail.com>

From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Vik Fearing <vik.fearing@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, Fabien COELHO <coelho@cri.ensmp.fr>, Stephen Frost <sfrost@snowman.net>, Chapman Flack <chap@anastigmatix.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-01-20T20:18:48Z
Lists: pgsql-hackers
On Mon, 20 Jan 2020 at 19:04, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>
> On 2020-Jan-20, Dean Rasheed wrote:
>
> > +       <entry>
> > +        greatest common divisor &mdash; the largest positive number that
> > +        divides both inputs with no remainder; returns <literal>0</literal> if
> > +        both inputs are zero
> > +       </entry>
>
> Warning, severe TOC/bikeshedding ahead.
>
> I don't know why, but this dash-semicolon sequence reads strange to me
> and looks out of place.  I would use parens for the first phrase and
> keep the semicolon, that is "greatest common divisor (the largest ...);
> returns 0 if ..."
>
> That seems more natural to me, and we're already using parens in other
> description <entry>s.
>

Hmm, OK. I suppose that's more logical because then the bit in parens
is the standard definition of gcd/lcm, and the part after the
semicolon is the implementation choice for the special case not
covered by the standard definition.

Regards,
Dean



Commits

  1. Add functions gcd() and lcm() for integer and numeric types.