Pristine Ack-5.5
[Ack-5.5.git] / lang / fortran / lib / libF77 / pow_di.c
1 #include "f2c.h"
2
3 double pow_di(ap, bp)
4 doublereal *ap;
5 integer *bp;
6 {
7 double pow, x;
8 integer n;
9
10 pow = 1;
11 x = *ap;
12 n = *bp;
13
14 if(n != 0)
15         {
16         if(n < 0)
17                 {
18                 if(x == 0)
19                         {
20                         return(pow);
21                         }
22                 n = -n;
23                 x = 1/x;
24                 }
25         for( ; ; )
26                 {
27                 if(n & 01)
28                         pow *= x;
29                 if(n >>= 1)
30                         x *= x;
31                 else
32                         break;
33                 }
34         }
35 return(pow);
36 }