Check out example codes for "c++ print byte as bit". It will help you in understanding the concepts better.

Code Example 1

#include <bitset>
...

char a = -58;    
std::bitset<8> x(a);
std::cout << x << '\n';

short c = -315;
std::bitset<16> y(c);
std::cout << y << '\n';

Learn ReactJs, React Native from akashmittal.com