Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "cmplrs/host.h"
00040
00041 int32 __powii(int32 ap, int32 n)
00042 {
00043 int32 pow;
00044
00045
00046 if(n != 0) {
00047 if (n<0) {
00048
00049
00050
00051
00052
00053 if ((ap!=1)&&(ap!=-1)) return(0);
00054 n = -n;
00055 }
00056 pow=1;
00057 for( ; ; )
00058 {
00059 if(n & 01)
00060 pow *= ap;
00061 if(n >>= 1)
00062 ap *= ap;
00063 else
00064 return(pow);
00065 }
00066 }
00067 else return(1);
00068 }
00069
00070 int64 __powll(int64 ap, int64 n)
00071 {
00072 int64 pow;
00073
00074
00075 if(n != 0) {
00076 if (n<0) {
00077
00078
00079
00080
00081
00082 if ((ap!=1)&&(ap!=-1)) return(0);
00083 n = -n;
00084 }
00085 pow=1;
00086 for( ; ; )
00087 {
00088 if(n & 01)
00089 pow = pow * ap;
00090 if(n >>= 1)
00091 ap = ap * ap;
00092 else
00093 return(pow);
00094 }
00095 }
00096 else return(1);
00097 }
00098
00099 int64 __powli(int64 ap, int32 n)
00100 {
00101 int64 pow;
00102
00103
00104 if(n != 0) {
00105 if (n<0) {
00106
00107
00108
00109
00110
00111 if ((ap!=1)&&(ap!=-1)) return(0);
00112 n = -n;
00113 }
00114 pow=1;
00115 for( ; ; )
00116 {
00117 if(n & 01)
00118 pow = pow * ap;
00119 if(n >>= 1)
00120 ap = ap * ap;
00121 else
00122 return(pow);
00123 }
00124 }
00125 else return(1);
00126 }
00127
00128 int32 __powil(int32 ap, int64 n)
00129 {
00130 int32 pow;
00131
00132
00133 if(n != 0) {
00134 if (n<0) {
00135
00136
00137
00138
00139
00140 if ((ap!=1)&&(ap!=-1)) return(0);
00141 n = -n;
00142 }
00143 pow=1;
00144 for( ; ; )
00145 {
00146 if(n & 01)
00147 pow = pow * ap;
00148 if(n >>= 1)
00149 ap = ap * ap;
00150 else
00151 return(pow);
00152 }
00153 }
00154 else return(1);
00155 }
00156
00157
00158
00159 int32 pow_ii(int32 *ap, int32 *bp)
00160 {
00161 int32 pow;
00162 pow=__powii(*ap,*bp);
00163 return pow;
00164 }
00165
00166 int64 pow_il(int32 *ap, int64 *bp)
00167 {
00168 int64 pow;
00169 pow=__powil(*ap,*bp);
00170 return pow;
00171 }
00172
00173 int64 pow_li(int64 *ap, int32 *bp)
00174 {
00175 int64 pow;
00176 pow=__powli(*ap,*bp);
00177 return pow;
00178 }
00179
00180 int64 pow_ll(int64 *ap, int64 *bp)
00181 {
00182 int64 pow;
00183 pow=__powll(*ap,*bp);
00184 return pow;
00185 }