标签:
#include <iostream> using namespace std; const int STATUS_SIZE = 30; int main() { int status = 0; //set status : set the fifth position is true status = status | 1 << 4; cout << status << endl; //test if the fifth position is true if (status >> 4 && 1) cout << "yes" << endl; else cout << "no" << endl; //test if all the position is true if (status == (1 << STATUS_SIZE - 1)) cout << "yes" << endl; else cout << "no" << endl; status = status | 1 << 2; cout << status << endl; //unset status : set the fifth position is false status = status & ~(1 << 4); cout << status << endl; }
标签:
原文地址:http://www.cnblogs.com/scarecrow-blog/p/4668035.html