2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libf2c / libF77 / pow_hh.c
blob3379d8a7f7cea056602f3a6b81e9b13ccd7a27e0
1 #include "f2c.h"
3 shortint
4 pow_hh (shortint * ap, shortint * bp)
6 shortint pow, x, n;
7 unsigned u;
9 x = *ap;
10 n = *bp;
12 if (n <= 0)
14 if (n == 0 || x == 1)
15 return 1;
16 if (x != -1)
17 return x == 0 ? 1 / x : 0;
18 n = -n;
20 u = n;
21 for (pow = 1;;)
23 if (u & 01)
24 pow *= x;
25 if (u >>= 1)
26 x *= x;
27 else
28 break;
30 return (pow);