📜  切换设置清除检查更改位 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:38.749000             🧑  作者: Mango

代码示例1
// Setting a bit
number |= 1UL << n;
// Clearing a bit
number &= ~(1UL << n);
// Toggling a bit
number ^= 1UL << n;
// Checking a bit
bit = (number >> n) & 1U;
// Changing the nth bit to x
number ^= (-x ^ number) & (1UL << n);