110515Sdlw /* 2*22938Skre * Copyright (c) 1980 Regents of the University of California. 3*22938Skre * All rights reserved. The Berkeley software License Agreement 4*22938Skre * specifies the terms and conditions for redistribution. 5*22938Skre * 6*22938Skre * @(#)pow_ri.c 5.1 06/07/85 710515Sdlw */ 810515Sdlw 910515Sdlw float pow_ri(ap, bp) 1010515Sdlw float *ap; 1110515Sdlw long int *bp; 1210515Sdlw { 1310515Sdlw double pow, x; 1410515Sdlw long int n; 1510515Sdlw 1610515Sdlw pow = 1; 1710515Sdlw x = *ap; 1810515Sdlw n = *bp; 1910515Sdlw 2010515Sdlw if(n != 0) 2110515Sdlw { 2210515Sdlw if(n < 0) 2310515Sdlw { 2410515Sdlw if(x == 0) 2510515Sdlw { 2610515Sdlw return(pow); 2710515Sdlw } 2810515Sdlw n = -n; 2910515Sdlw x = 1/x; 3010515Sdlw } 3110515Sdlw for( ; ; ) 3210515Sdlw { 3310515Sdlw if(n & 01) 3410515Sdlw pow *= x; 3510515Sdlw if(n >>= 1) 3610515Sdlw x *= x; 3710515Sdlw else 3810515Sdlw break; 3910515Sdlw } 4010515Sdlw } 4110515Sdlw return(pow); 4210515Sdlw } 43