fork download
  1. #include <iostream>
  2. #include <bitset>
  3. using namespace std;
  4.  
  5. template<typename T, typename U>
  6. union ultra_cast {
  7. public:
  8. constexpr ultra_cast(T t) : t_(t) {}
  9. operator U() const { return u_; }
  10.  
  11. private:
  12. T t_;
  13. U u_;
  14. };
  15.  
  16. int main() {
  17. float a = 1.0f;
  18. uint32_t b = ultra_cast<float, uint32_t>(a);
  19. cout << bitset<32>(b) << endl;
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
00111111100000000000000000000000