fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. enum A{a=9223372036854775808,b=~9223372036854775808+1};
  6.  
  7. template<typename T>
  8. void dump(const T& value)
  9. {
  10. union {
  11. T value;
  12. unsigned char bytes[sizeof(T)];
  13. } v;
  14.  
  15. std::cout << "signed=" << (~T(0)<0) << std::endl;
  16.  
  17. v.value = value;
  18. for (size_t i = sizeof(v.bytes); i > 0; --i)
  19. std::cout << std::hex << std::setfill('0') << std::setw(2) << (unsigned int)v.bytes[i-1];
  20. std::cout << std::endl;
  21. }
  22.  
  23. int main()
  24. {
  25.  
  26. cout << sizeof(a) << endl;
  27. dump(a);
  28. dump(b);
  29.  
  30.  
  31. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
8
signed=0
8000000000000000
signed=0
8000000000000000