Re: Issues with factorial operator

From: "Cui Shijun" <rancpine(at)gmail(dot)com>
To: "Dann Corbit" <DCorbit(at)connx(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issues with factorial operator
Date: 2007-06-09 10:20:10
Message-ID: 306760850706090320i72b45438vc3f6725b8d8318ab@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

yeah, simple and correct, I like that. :-)

2007/6/9, Dann Corbit <DCorbit(at)connx(dot)com>:
> > -----Original Message-----
> [snip]
> > Hum... I think there is a little improvement: when n is too large,(say
> > n>10, 000) we can use Stirling's formula to get the estimated value of
> > n! :-)
>
> Or (rather) the log base 10 of Stirling's formula. The n! estimator
> will overflow for sure, unless we take the log of it.
>
> Rather than all that, why not just figure out what the largest number of
> digits we will allow is and then don't allow inputs that will generate
> more than that.
>
> The program I gave could be run with the target accuracy as the break
> out of the loop and then the test would be:
>
> <type> factorial(<type> n)
> {
> if (n > CONSTANT_PRECOMPUTED_LIMIT)
> return NULL;
> else
> {
> return compute_actual_factorial(n);
> }
> }
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Lukas Kahwe Smith 2007-06-09 12:11:42 Re: Using the GPU
Previous Message Markus Schiltknecht 2007-06-09 10:08:59 Re: COPYable logs status