π
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
| #Basic Tricks | |
| Check if a number is odd/even | |
| if ((n & 1) == 1) β odd | |
| if ((n & 1) == 0) β even | |
| Check if k-th bit is set | |
| if ((n & (1 << k)) != 0) β k-th bit is 1 | |
| Set the k-th bit | |
| n | (1 << k) |
OlderNewer