dynare/dynare++/utils/cc/int_power.cc

14 lines
149 B
C++

int
power(int a, int b)
{
int res = 1;
while (b > 0)
{
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}