1 #include "v3p_f2c.h" 2 #ifdef __cplusplus 3 extern "C" { 4 #endif 5 6 /* The divide by zero below appears to be perhaps on purpose to create 7 a numerical exception. */ 8 #ifdef _MSC_VER 9 # pragma warning (disable: 4723) /* potential divide by 0 */ 10 #endif 11 12 #ifdef KR_headers pow_ii(ap,bp)13integer pow_ii(ap, bp) integer *ap, *bp; 14 #else 15 integer pow_ii(integer *ap, integer *bp) 16 #endif 17 { 18 integer pow, x, n; 19 unsigned long u; 20 21 x = *ap; 22 n = *bp; 23 24 if (n <= 0) { 25 if (n == 0 || x == 1) 26 return 1; 27 if (x != -1) 28 return x == 0 ? 1/x : 0; 29 n = -n; 30 } 31 u = n; 32 for(pow = 1; ; ) 33 { 34 if(u & 01) 35 pow *= x; 36 if(u >>= 1) 37 x *= x; 38 else 39 break; 40 } 41 return(pow); 42 } 43 #ifdef __cplusplus 44 } 45 #endif 46