freebsd-dev/contrib/libf2c/libF77/pow_di.c

33 lines
347 B
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
#include "f2c.h"
2003-07-11 03:42:19 +00:00
double
pow_di (doublereal * ap, integer * bp)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
double pow, x;
integer n;
unsigned long u;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
pow = 1;
x = *ap;
n = *bp;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
if (n != 0)
{
if (n < 0)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
n = -n;
x = 1 / x;
1999-09-18 10:51:31 +00:00
}
2003-07-11 03:42:19 +00:00
for (u = n;;)
{
if (u & 01)
pow *= x;
if (u >>= 1)
x *= x;
else
break;
}
}
return (pow);
1999-09-18 10:51:31 +00:00
}