correct #ifdef's (from jim mckie)
[unix-history] / usr / src / usr.bin / f77 / libF77 / pow_ri.c
CommitLineData
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 *
af857331 6 * @(#)pow_ri.c 5.3 %G%
683456d4
DW
7 */
8
9float pow_ri(ap, bp)
10float *ap;
11long int *bp;
12{
13double pow, x;
14long int n;
15
16pow = 1;
17x = *ap;
18n = *bp;
19
20if(n != 0)
21 {
22 if(n < 0)
23 {
24 if(x == 0)
25 {
af857331 26 return(pow);
683456d4
DW
27 }
28 n = -n;
29 x = 1/x;
30 }
af857331
KM
31 if (x == 0)
32 return(0);
33
683456d4
DW
34 for( ; ; )
35 {
36 if(n & 01)
37 pow *= x;
38 if(n >>= 1)
39 x *= x;
40 else
41 break;
42 }
43 }
af857331 44return(pow);
683456d4 45}