fork download
  1. #include <iostream>
  2. #include <bitset>
  3. #include <inttypes.h>
  4.  
  5. union Key64
  6. {
  7. uint64_t All;
  8. struct
  9. {
  10. uint64_t Low : 16;
  11. uint64_t Mid : 32;
  12. uint64_t High : 16;
  13. };
  14. };
  15.  
  16. int main()
  17. {
  18. Key64 key;
  19. key.All = 0x9B1253F0FC539EEDUL; //1001101100010010010100111111000011111100010100111001111011101101
  20.  
  21. std::cout << "1001101100010010010100111111000011111100010100111001111011101101" << " [Should be]" << std::endl;
  22.  
  23. std::cout << "" << std::bitset<32>((key.All >> 32) & 0xFFFFFFFF) << std::bitset<32>(key.All & 0xFFFFFFFF) << " [All 64 bits]"<< std::endl;
  24. std::cout << " " << std::bitset<16>(key.Low & 0x0000FFFF) << "" << " [Low 16 bits]"<< std::endl;
  25. std::cout << " " << std::bitset<32>(key.Mid & 0xFFFFFFFF) << " " << " [Mid 32 bits]" << std::endl;
  26. std::cout << "" << std::bitset<16>(key.High & 0x0000FFFF) << " " << " [High 16 bits]" << std::endl;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
1001101100010010010100111111000011111100010100111001111011101101 [Should be]
1001101100010010010100111111000011111100010100111001111011101101 [All 64 bits]
                                                1001111011101101 [Low 16 bits]
                01010011111100001111110001010011                 [Mid 32 bits]
1001101100010010                                                 [High 16 bits]