fork download
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. int main()
  5. {
  6. std::bitset<sizeof(int)*8> a{345}, b{345 / 0xF};
  7. std::cout << a.to_string() << (char)10 << b.to_string(); // sorry, bin gerade unter mac, finde den backward-slash nicht
  8. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
00000000000000000000000101011001
00000000000000000000000000010111