#include <bitset> using std::bitset; //16 is the output bit number of x. cout << bitset<16>(x) << endl;