#include <iostream>
#include <bitset>
using namespace std;
int main() {
// int number = 7;
short s = -5;
cout << "Binary representation of " << s << ": ";
cout << bitset<sizeof(short) * 8>(s) << endl;
unsigned int i = s;
cout << "Binary representation of " << i << ": ";
cout << bitset<sizeof(unsigned int) * 8>(i) << endl;
// cout << "Binary representation of " << i << ": ";
// cout << bitset<sizeof(int) * 8>(i) << endl;
return 0;
}
输出变量的机器数表示
最新推荐文章于 2024-06-09 20:18:37 发布