← Back to Games

💡 Bit Detector

Detect if the ith bit is set - light up the truth!

🔍 Detection Panel
n & (1 << i) → Check bit i
?
Number (n) 0

📚 Check if ith Bit is Set

To check if the ith bit is set (equals 1), use AND with a mask:

isSet = (n & (1 << i)) != 0

// Example: Check bit 3 of 42 (00101010)
// 1 << 3 = 00001000
// 42 & 8 = 00001000 = 8 (not zero!)
// Bit 3 is SET ✓

If the result is non-zero, the bit is ON. If zero, the bit is OFF.