Created
December 17, 2010 05:05
-
-
Save aont/744515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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