位运算:左移

This commit is contained in:
flykhan 2023-06-19 14:09:46 +08:00
parent 30bd068d05
commit b1523467f8
1 changed files with 15 additions and 0 deletions

15
day6/d2.cpp Normal file
View File

@ -0,0 +1,15 @@
// 测试移位运算
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
char n = 0b11000011;
cout << "n = " << bitset<8>(n) << endl;
n = n << 2; // 建议不要使用 <<= 复合运算符,注意符号位也会移动
cout << "n = " << bitset<8>(n) << "\t" << (int)n << endl;
return 0;
}