In c++ we can use bit set to check the binary formation of a int value.
int a = -1;
std::bitset<32> b(a);
cout << b << endl;
The output
11111111111111111111111111111111
We also can loop every bits and output it.
void binary_formation(int x) {
for (int i = 31; i >= 0; --i) {
cout << (((1 << i) & x) ? 1 : 0);
}
cout << endl;
}