Skip to content

Instantly share code, notes, and snippets.

@naotokui
Created August 21, 2014 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naotokui/f70eddddbcb7c96f6a07 to your computer and use it in GitHub Desktop.
Save naotokui/f70eddddbcb7c96f6a07 to your computer and use it in GitHub Desktop.
check if a number is 2^N
if ((num & (num - 1)) == 0){
// num is 2^N
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment