Setting k-th bit of x: x |= 1 [shift] k Clearing k-th bit: x &= ~(1 [shift] k) Getting k-th bit: return (x [shift] k) & 1 Flipping k-th bit: x ^= 1 [shift] k (replaces 0 by 1, and 1 by 0.)
沒有留言:
張貼留言