#include <iostream> #include <bitset>
using namespace std;
int main() { bitset<12>mask(127); bitset<12>haha(128); cout << "mask= " << mask << endl; cout << mask.to_ulong() << endl; cout << "haha= " << haha << endl; haha |= mask; cout << "haha|mask= " << haha << endl; haha &= mask; cout << "haha&mask= " << haha << endl; haha ^= mask; cout << "haha^mask= " << haha << endl;
return 0; }
|
Tencent:/data/kenthy/stl/bitset # ./bitset
mask= 000001111111
127
haha= 000010000000
haha|mask= 000011111111
haha&mask= 000001111111
haha^mask= 000000000000
很奇怪的是,求| ^ &的时候,需要bitset的位数是一样的....
阅读(1639) | 评论(0) | 转发(0) |