跳转到内容
新建笔记

编程技巧

// 比如想操作3位bit,111 = 2^3-1 = 7
int num = 7; // 初始数字7
int result = num;
// 将其中第2位置0
result &= ~(1 << 1);
// 将前两位置0
result &= ~((1 << 2) - 1);
// 将后2位置0
// 将1 , 3位置0
result &= ~(1 | (1 << 2));