How to check if the i-th bit is set?

Updated Apr 28, 2026

Short answer

Right shift and check LSB: (num >> i) & 1.

Deep explanation

Bit manipulation at the hardware level is faster than arithmetic. Right shift and check LSB: (num >> i) & 1. This is fundamental for low-level optimization.

Real-world example

Flag management in simple game engines.

Common mistakes

  • Forgetting that bitwise operators have lower precedence than comparison operators.

Follow-up questions

  • What is 1 << 3?

More Bit Manipulation interview questions

View all →