Compare commits

..

No commits in common. "49565a55df6f00b56f5446f3da7b3021639aed19" and "6f86054fb618fc38b631c8d6f6cc49b9fe1fa7c4" have entirely different histories.

2 changed files with 0 additions and 48 deletions

View File

@ -1,20 +0,0 @@
/*
0b 1100 0011 << 2 -67
0b 0000 1100 12
0.
[].
*/
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
char n = 0b11000011; // 0b 表示二进制表示法 0b11000011 = 195
cout << "n = " << bitset<8>(n) << endl; // n = 11000011
n = n << 2; // 建议不要使用 <<= 运算符,因为它会改变 n 的类型 // 0b00001100 = 12 195 << 2 = 12
cout << "n = " << bitset<8>(n) << "\t" << (int)n << endl; // n = 00001100
return 0;
}

View File

@ -1,28 +0,0 @@
/*
(), ,,0,.,.
*/
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
char n = 0xff; // 0b1111 1111
/*
.,0,,,.,,0,,1.
.,0,.,1,.,,.
*/
n = n >> 4; // 逻辑右移: 0b0000 1111 ; 算术右移: 0b1111 1111
// 如何判断高 4 位是 1111 还是 0000
// 1. 逻辑右移, 0b0000 1111
// 2. 算术右移, 0b1111 1111
if (n & 0xff == 0x0f)
cout << "0xff >> 4 进行逻辑右移, 结果: " << bitset<8>(n) << endl;
else
cout << "0xff >> 4 进行算术右移, 结果: " << bitset<8>(n) << endl;
return 0;
}