记录一下位操作:
/* index:[0, 7] */ bool SetOrCleanBit(unsigned char& data, int index, bool enable) { if (index < 0 || index > 7) { return false; } if (enable) data |= (1 << index); else data &= ~(1 << index); return true; } /* index:[0, 7] */ int GetBit(char ch, int index)//0101 1010,2->1 { if (index < 0 || index > 7) { return false; } return (ch >> index) & 1; }