On Sat, 26 Mar 2005 22:31:52 +0800, Steven Schubiger
<[EMAIL PROTECTED]> wrote:
typedef (malloc(2*sizeof(long double))) Big_Double;
Big_Double var;
Sorry my C is barely Novice.
Where can I put this snippet in my C subroutine?
like this:
[snip code]
__END__
__C__
typedef (malloc(2*sizeof(long double))) Big_Double;
Big_Double factrl;
double factrl(int n)
{
double gammln(double xx);
void nerror(char error_text[]);
static int ntop=4;
static double a[33]={1.0,1.0,2.0,6.0,24.0};
int j;
if (n<0) nerror("Negative factorial in routine factrl");
if (n>32) return exp(gammln(n+1.0));
while (ntop<n){
j = ntop++;
a[ntop]=a[j]*ntop;
}
return a[n];
}
double gammln(double xx)
{
double x,y, tmp,ser;
static double cof[6] = {76.18009172947146, -86.50532032941677,
24.01409824083091, -1.231739572450155,
0.12086509738661e-2, -0.5395239384953e-5};
int j;
y = x = xx;
tmp= x+5.5;
tmp -= (x+0.5)*log(tmp);
ser=1.000000000190015;
for (j=0;j<=5;j++) ser += cof[j]/++y;
return -tmp+log(2.5066282746310005*ser/x);
}
--
Edward WIJAYA
Singapore
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>