Re: factorial of negative numbers

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: factorial of negative numbers
Дата
Msg-id 20200616085518.GA31175@momjian.us
обсуждение исходный текст
Ответ на Re: factorial of negative numbers  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: factorial of negative numbers  (Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>)
Re: factorial of negative numbers  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
On Tue, Jun 16, 2020 at 08:31:21AM +0100, Dean Rasheed wrote:
> On Tue, 16 Jun 2020 at 06:00, Ashutosh Bapat
> <ashutosh.bapat@2ndquadrant.com> wrote:
> >
> > Divison by zero is really undefined, 12345678 * 12345678 (just some numbers) is out of range of say int4, but
factorialof a negative number has some meaning and is defined but PostgreSQL does not support it.
 
> >
> 
> Actually, I think undefined/out-of-range is the right error to throw here.
> 
> 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.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee




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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Asynchronous Append on postgres_fdw nodes.
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: PATCH: logical_work_mem and logical streaming of largein-progress transactions