From b1523467f85b7287c86cf634ecabf229d14e3567 Mon Sep 17 00:00:00 2001 From: flykhan Date: Mon, 19 Jun 2023 14:09:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E8=BF=90=E7=AE=97:=E5=B7=A6=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/d2.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 day6/d2.cpp diff --git a/day6/d2.cpp b/day6/d2.cpp new file mode 100644 index 0000000..9c86ca0 --- /dev/null +++ b/day6/d2.cpp @@ -0,0 +1,15 @@ +// 测试移位运算 +#include +#include + +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; +} +