Here are the four operations you'll use constantly:
• Check if bit is set:
• Set bit :
• Clear bit :
• Toggle bit :
The pattern appears everywhere because it creates a number with only bit set. Memorize these four operations. You'll use them in almost every bit manipulation problem.