Chinaunix首页 | 论坛 | 博客
  • 博客访问: 416565
  • 博文数量: 67
  • 博客积分: 2468
  • 博客等级: 上尉
  • 技术积分: 1050
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-05 01:21
文章分类

全部博文(67)

文章存档

2013年(1)

2012年(65)

2011年(1)

分类: C/C++

2012-07-25 15:00:01

点击(此处)折叠或打开

  1. /*C provides six operators (&, |, ^, <<, >>,~)for bit manipulation;
  2.  * these may only be applied to integral operands, that is, char, short, int,
  3.  * and long,whether signed or unsigned.
  4.  */

  5. #include <iostream>
  6. using namespace std;

  7. int main() {
  8.     cout << "!!!Hello World!!!" << endl; // prints !!!Hello

  9.     /*二进制输出*/
  10.     cout.setf(ios::hex,ios::basefield);

  11.     int i = 0x80000000;
  12.     cout << "i = " << i <<endl;
  13.     i = i >> 1;
  14.     cout << "after move i = " << i << endl;

  15.     unsigned int ui = 0x80000000;
  16.     cout << "ui = " << ui <<endl;
  17.     ui = ui >> 1;
  18.     cout << "after move ui = " << ui << endl;

  19.     return 0;
  20. }
  21. //right shift
  22. //!!!Hello
  23. //i = 80000000
  24. //after move i = c0000000
  25. //ui = 80000000
  26. //after move ui = 40000000*/

  27. //left shift
  28. //!!!Hello
  29. //i = 80000000
  30. //after move i = 0
  31. //ui = 80000000
  32. //after move ui = 0

阅读(2906) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~