Skip to content

Instantly share code, notes, and snippets.

@aont
Created December 17, 2010 05:05
Show Gist options
  • Select an option

  • Save aont/744515 to your computer and use it in GitHub Desktop.

Select an option

Save aont/744515 to your computer and use it in GitHub Desktop.
template<typename Out,typename In>
Out log2(In x)
{
for(Out i = 0; i<sizeof(In)*8; ++i){
x = x >> 1;
if(!x)
return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment