Skip to content

Instantly share code, notes, and snippets.

View AFFogarty's full-sized avatar

Andrew Fogarty AFFogarty

View GitHub Profile
@AFFogarty
AFFogarty / isPowerOfTwo()
Last active August 29, 2015 14:06
C function that tests if an integer is a power of 2
bool isPowerOfTwo(int i)
{
while (i != 0)
{
if (i == 1) return true;
else i >> 1;
}
return false;
}