← Back to Games

⬆️ Bit Upgrade Forge

Turn ON the ith bit - forge your number with bitwise OR!

🔧 The Forge
n | (1 << i) → Turn ON bit i
Original Number (n) 0
Mask (1 << i) 0
Result (n | mask) 0

📚 Turn ON the ith Bit

To turn ON (set to 1) the ith bit of a number, use OR with a mask:

result = n | (1 << i)

// Example: Turn on bit 4 of 42
// 42 = 00101010
// 1 << 4 = 00010000
// OR -----------
// 58 = 00111010

The mask (1 << i) has only bit i set to 1. ORing with this mask ensures bit i becomes 1, leaving other bits unchanged.