fork download
  1. #include <bitset>
  2. #include <cstdio>
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7. std::bitset<8> b1(std::string("01100100")); std::cout<<b1<<std::endl;
  8. std::bitset<8> b2(std::string("11111111")); std::cout<<b2<<std::endl; //see, this variable
  9. //has been assigned
  10. //the value 11111111
  11. //whereas, during
  12. //execution, it takes
  13. //the value 11000111
  14. std::cout << "b1 & b2: " << (b1 & b2) << '\n';
  15. std::cout << "b1 | b2: " << (b1 | b2) << '\n';
  16. std::cout << "b1 ^ b2: " << (b1 ^ b2) << '\n';
  17. getchar();
  18. return 0;
  19. }
Success #stdin #stdout 0s 2992KB
stdin
Standard input is empty
stdout
01100100
11111111
b1 & b2: 01100100
b1 | b2: 11111111
b1 ^ b2: 10011011