1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)pow_ri.c 5.5 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 #ifdef tahoe 13 #define double float 14 #endif /* tahoe */ 15 16 float 17 pow_ri(ap, bp) 18 float *ap; 19 long *bp; 20 { 21 register long n = *bp; 22 #ifdef tahoe 23 register 24 #endif /* tahoe */ 25 double y, x = *ap; 26 27 if (!n) 28 return((double)1); 29 if (n < 0) { 30 x = (double)1 / x; 31 n = -n; 32 } 33 while (!(n&1)) { 34 x *= x; 35 n >>= 1; 36 } 37 for (y = x; --n > 0; y *= x) 38 while (!(n&1)) { 39 x *= x; 40 n >>= 1; 41 } 42 return(y); 43 } 44 #ifdef tahoe 45 #undef double 46 #endif /* tahoe */ 47