输出变量的机器数表示

#include 
#include 
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(i) << endl;
    return 0;
}

你可能感兴趣的:(计算机组成,C++,计算机组成原理,c++)