From: | Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)2ndquadrant(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: factorial of negative numbers |
Date: | 2020-06-16 09:08:56 |
Message-ID: | CAC+AXB2mQvAiXoBffX=xbmovTBjqGmuYOpGW-osmRiyt9gqK1Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jun 16, 2020 at 10:55 AM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> On Tue, Jun 16, 2020 at 08:31:21AM +0100, Dean Rasheed wrote:
> >
> > Most common implementations do regard factorial as undefined for
> > anything other than positive integers, as well as following the
> > convention that factorial(0) = 1. Some implementations extend the
> > factorial to non-integer inputs, negative inputs, or even complex
> > inputs by defining it in terms of the gamma function. However, even
> > then, it is undefined for negative integer inputs.
>
> Wow, they define it for negative inputs, but not negative integer
> inputs? I am curious what the logic is behind that.
>
It is defined as NaN (or undefined), which is not in the realm of integer
numbers. You might get a clear idea of the logic from [1], where they also
make a case for the error being ERRCODE_DIVISION_BY_ZERO.
[1] http://mathforum.org/library/drmath/view/60851.html
Regards,
Juan José Santamaría Flecha
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2020-06-16 09:22:12 | Re: pg_upgrade fails if vacuum_defer_cleanup_age > 0 |
Previous Message | Amit Kapila | 2020-06-16 09:06:55 | Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions |