Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
pow_qq.c
Go to the documentation of this file.00001 #include "f2c.h"
00002
00003 #ifdef KR_headers
00004 longint pow_qq(ap, bp) longint *ap, *bp;
00005 #else
00006 longint pow_qq(longint *ap, longint *bp)
00007 #endif
00008 {
00009 longint pow, x, n;
00010 unsigned long long u;
00011
00012 x = *ap;
00013 n = *bp;
00014
00015 if (n <= 0) {
00016 if (n == 0 || x == 1)
00017 return 1;
00018 if (x != -1)
00019 return x == 0 ? 1/x : 0;
00020 n = -n;
00021 }
00022 u = n;
00023 for(pow = 1; ; )
00024 {
00025 if(u & 01)
00026 pow *= x;
00027 if(u >>= 1)
00028 x *= x;
00029 else
00030 break;
00031 }
00032 return(pow);
00033 }