|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)pow_ri.c 5.4 1/24/88
7: */
8:
9: #ifdef tahoe
10: #define double float
11: #endif /* tahoe */
12:
13: float
14: pow_ri(ap, bp)
15: float *ap;
16: long *bp;
17: {
18: register long n = *bp;
19: #ifdef tahoe
20: register
21: #endif /* tahoe */
22: double y, x = *ap;
23:
24: if (!n)
25: return((double)1);
26: if (n < 0) {
27: x = (double)1 / x;
28: n = -n;
29: }
30: while (!(n&1)) {
31: x *= x;
32: n >>= 1;
33: }
34: for (y = x; --n > 0; y *= x)
35: while (!(n&1)) {
36: x *= x;
37: n >>= 1;
38: }
39: return(y);
40: }
41: #ifdef tahoe
42: #undef double
43: #endif /* tahoe */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.