You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
430 B
34 lines
430 B
#include <soft.h>
|
|
|
|
/*
|
|
computes a^b.
|
|
uses log and exp
|
|
need error handling
|
|
*/
|
|
|
|
double pow(double arg1, double arg2)
|
|
{
|
|
double temp;
|
|
long l;
|
|
|
|
if(arg1 <= 0.) {
|
|
if(arg1 == 0.) {
|
|
if(arg2 <= 0.)
|
|
goto domain;
|
|
return(0.);
|
|
}
|
|
l = arg2;
|
|
if(l != arg2)
|
|
goto domain;
|
|
temp = exp(arg2 * log(-arg1));
|
|
if(l & 1)
|
|
temp = -temp;
|
|
return(temp);
|
|
}
|
|
return(exp(arg2 * log(arg1)));
|
|
|
|
domain:
|
|
errno = EDOM;
|
|
return(0.);
|
|
}
|