static float pow(float base, int exp) {
float result = 1;
if(exp<0) return 1.0f/pow(base,-exp);
while (exp!=0) {
if ((exp & 1)!=0) result *= base;
exp >>= 1;
base *= base;
}
return result;
}
Subscribe to:
Post Comments (Atom)
collection of code snippets that might be helpful
No comments:
Post a Comment