Re: Bug #534: factorial function

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: j(dot)richter(at)wallstreet-develop(dot)de, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #534: factorial function
Date: 2002-02-23 01:06:08
Message-ID: 200202230106.g1N169Z23526@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

pgsql-bugs(at)postgresql(dot)org wrote:
> Janko Richter (j(dot)richter(at)wallstreet-develop(dot)de) reports a bug
> with a severity of 3 The lower the number the more severe it
> is.
>
> Short Description factorial function
>
> Long Description 1. The factorial function returns 0 when the
> argument is 0. The factorial Funtion is defined as: factorial(0)=1

I have fixed factorial(0)=1 in 7.3.

> 2. It would be better to define a factorial function returning
> double precision. The factorial function returning bigint produces
> false values with arguments larger then 20.
>
> Notice: I'm using the factorial function for statistical functions
> (for example poisson distribution)
>
> Thank you.
>
>
> Sample Code test=# select factorial(0);
> factorial -----------
> 0
> (1 row)
>
> janko=# select factorial(21::bigint);
> factorial ----------------------
> -4249290049419214848 (1 row)

The problem here is that we don't have a bigint version of factorial,
just an int8 version. This is now on the TODO list:

* Change factorial to return a numeric

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2002-02-23 02:10:18 Re: COPY when 'filename' is a directory
Previous Message Tom Lane 2002-02-23 00:36:26 Re: CURRENT_TIMESTAMP not work correctly insinde a transaction.