fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <boost/multiprecision/cpp_int.hpp>
  5.  
  6. using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
  7.  
  8. int main() {
  9. std::stringstream stream;
  10. u256 data=0xFEDEFA;
  11. data <<= 128;
  12. for (int i = 0; i<32; ++i) {
  13. uint8_t dataByte = int(data & 0xFF);
  14. data >>= 8;
  15. stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex << int(dataByte) << " ";
  16. }
  17. std::cout << stream.str();
  18. }
Success #stdin #stdout 0s 4296KB
stdin
Standard input is empty
stdout
00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  fa  de  fe  00  00  00  00  00  00  00  00  00  00  00  00  00