fork download
  1. #include<algorithm>
  2. #include<bitset>
  3. #include<cstring>
  4. #include<iomanip>
  5. #include<iostream>
  6. #include<iterator>
  7. #include<memory>
  8. using namespace std;
  9.  
  10. template<class Src,class Des>
  11. inline void copy_to(const Src &src,Des &des) noexcept
  12. {
  13. memcpy(addressof(des),addressof(src),sizeof(Src));
  14. }
  15.  
  16. int main()
  17. {
  18. unsigned char c[4];
  19. copy_to(185433.324f,c);
  20. for_each(rbegin(c),rend(c),[](const auto val){cout<<bitset<sizeof(unsigned char)*8>{val};});
  21. cout<<endl;
  22.  
  23. float f;
  24. copy_to(c,f);
  25. cout<<fixed<<setprecision(8)<<f<<endl;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
01001000001101010001011001010101
185433.32812500