bitset 来计算位 在stl中提供了 bitset<N> 来计算位,非常方便。 尤其是计算键盘的状态时游泳 short s = 32757; bitset<16> bs = s; cout<<bs[15]<<endl; //得到最高位是0 或者 1