fork download
  1. #include <iostream>
  2. #include <bitset>
  3. #include <string>
  4. #include <stdint.h>
  5.  
  6. using namespace std;
  7.  
  8. union Converter { uint32_t bts; float f; };
  9.  
  10. int main()
  11. {
  12. std::string temp = "11000000011000000000000000000000";
  13. bitset<32> sourceBits( temp );
  14. Converter convert;
  15. convert.bts = sourceBits.to_ulong();
  16. cout << convert.f;
  17. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
-3.5