1*47940Sbostic /*- 2*47940Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47940Sbostic * All rights reserved. 422928Skre * 5*47940Sbostic * %sccs.include.proprietary.c% 610512Sdlw */ 710512Sdlw 8*47940Sbostic #ifndef lint 9*47940Sbostic static char sccsid[] = "@(#)pow_di.c 5.4 (Berkeley) 04/12/91"; 10*47940Sbostic #endif /* not lint */ 11*47940Sbostic 1233364Sbostic double pow_di(ap,bp)1333364Sbosticpow_di(ap, bp) 1433364Sbostic double *ap; 1533364Sbostic long *bp; 1610512Sdlw { 1733364Sbostic register long n = *bp; 1833364Sbostic double y, x = *ap; 1910512Sdlw 2033364Sbostic if (!n) 2133364Sbostic return((double)1); 2233364Sbostic if (n < 0) { 2333364Sbostic x = (double)1 / x; 2410512Sdlw n = -n; 2533364Sbostic } 2633364Sbostic while (!(n&1)) { 2733364Sbostic x *= x; 2833364Sbostic n >>= 1; 2933364Sbostic } 3033364Sbostic for (y = x; --n > 0; y *= x) 3133364Sbostic while (!(n&1)) { 3210512Sdlw x *= x; 3333364Sbostic n >>= 1; 3410512Sdlw } 3533364Sbostic return(y); 3610512Sdlw } 37