Commit | Line | Data |
---|---|---|
683456d4 | 1 | /* |
a7868ad7 RE |
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 | * | |
95f51977 | 6 | * @(#)pow_ri.c 5.2 7/9/85 |
683456d4 DW |
7 | */ |
8 | ||
95f51977 C |
9 | float flt_retval; |
10 | ||
683456d4 DW |
11 | float pow_ri(ap, bp) |
12 | float *ap; | |
13 | long int *bp; | |
14 | { | |
15 | double pow, x; | |
16 | long int n; | |
17 | ||
18 | pow = 1; | |
19 | x = *ap; | |
20 | n = *bp; | |
21 | ||
22 | if(n != 0) | |
23 | { | |
24 | if(n < 0) | |
25 | { | |
26 | if(x == 0) | |
27 | { | |
95f51977 C |
28 | flt_retval = pow; |
29 | return(flt_retval); | |
683456d4 DW |
30 | } |
31 | n = -n; | |
32 | x = 1/x; | |
33 | } | |
34 | for( ; ; ) | |
35 | { | |
36 | if(n & 01) | |
37 | pow *= x; | |
38 | if(n >>= 1) | |
39 | x *= x; | |
40 | else | |
41 | break; | |
42 | } | |
43 | } | |
95f51977 C |
44 | flt_retval = pow; |
45 | return(flt_retval); | |
683456d4 | 46 | } |