#include <iostream> #include <iomanip> #include <format> using namespace std; int main() { unsigned short num1 = 128+32+8+4+2; unsigned short bit = 1; int count = 0; cout << "working with " << num1 << endl; cout << endl; string answer{""}; while (count < sizeof(bit) * 8 - 1) { int digit = bit & num1; // cout << digit << endl; if(digit) { answer = "1" + answer ; } else { answer = "0" + answer ; } bit = bit << 1; ++count; } cout << answer << endl; return 0; }