Last active
August 29, 2015 14:06
-
-
Save Nan-Zhang/566bc1d0ec200c13935d to your computer and use it in GitHub Desktop.
This file contains 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
show ith of a: a & 1 << i | |
reset ith of a: a &= ~(1 << i) | |
populate the result: result |= 1 << i | |
(-i) & i; //NOTE from right to left, get first '1' and other bits is '0' | |
n & (n - 1) == 0 check if n is power of 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment