点击(此处)折叠或打开
- /*C provides six operators (&, |, ^, <<, >>,~)for bit manipulation;
- * these may only be applied to integral operands, that is, char, short, int,
- * and long,whether signed or unsigned.
- */
- #include <iostream>
- using namespace std;
- int main() {
- cout << "!!!Hello World!!!" << endl; // prints !!!Hello
- /*二进制输出*/
- cout.setf(ios::hex,ios::basefield);
- int i = 0x80000000;
- cout << "i = " << i <<endl;
- i = i >> 1;
- cout << "after move i = " << i << endl;
- unsigned int ui = 0x80000000;
- cout << "ui = " << ui <<endl;
- ui = ui >> 1;
- cout << "after move ui = " << ui << endl;
- return 0;
- }
- //right shift
- //!!!Hello
- //i = 80000000
- //after move i = c0000000
- //ui = 80000000
- //after move ui = 40000000*/
- //left shift
- //!!!Hello
- //i = 80000000
- //after move i = 0
- //ui = 80000000
- //after move ui = 0