Files
Arquivotheca.SunOS-4.1.4/usr.lib/libm/C/compound.c
seta75D ff309bfe1c Init
2021-10-11 18:37:13 -03:00

28 lines
414 B
C

#ifndef lint
static char sccsid[] = "@(#)compound.c 1.1 94/10/31 SMI";
#endif
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
*/
/* compound(r,n)
*
* Returns (1+r)**n; undefined for r <= -1.
*/
#include <math.h>
double compound(r,n)
double r,n;
{
double w;
if(n==0.0) return 1.0;
if(r!=r) return r+r;
w = fabs(r);
if(r<-1.0||fabs(r)<=0.5)
return exp(n*log1p(r));
else
return pow(1.0+r,n);
}