Given an integer x and a zero-based index n, clear (unset) the n-th bit of x and return the resulting value. Clearing sets the n-th bit to 0 while leaving all other bits unchanged.
Create a mask that has all bits 1 except a 0 at position n by computing ~(1 << n). AND-ing x with this mask clears the n-th bit while preserving other bits.
In languages where integers are signed or have implementation-defined widths, mask results to the intended unsigned width when necessary (e.g., & 0xFFFFFFFF).
The mask ~(1 << n) turns on all bits except the n-th, making x & mask a concise way to clear the target bit. This is the same primitive shown in many bit-hack collections.