Skip to content

Instantly share code, notes, and snippets.

@simon-engledew
Created November 4, 2019 11:43
Show Gist options
  • Save simon-engledew/573538fa040b9d560804a0eb0dfa31fd to your computer and use it in GitHub Desktop.
Save simon-engledew/573538fa040b9d560804a0eb0dfa31fd to your computer and use it in GitHub Desktop.
knuth intpow
unsigned int intpow(unsigned int a, unsigned int b)
{
unsigned int p = 1;
for (; b > 0;)
{
if ((b & 1) != 0)
{
p *= a;
}
b >>= 1;
a *= a;
}
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment