fork download
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int al = 100;
  9. float x = 0, y = 0;
  10.  
  11. x = *(float *)&al;
  12. y = al;
  13.  
  14. bitset<32> a(al);
  15. bitset<32> b(*(int *)&x);
  16. bitset<32> c(*(int *)&y);
  17.  
  18. cout << al << "\t\t" << a.to_string() << endl;
  19. cout << x << "\t\t" << b.to_string() << endl;
  20. cout << y << "\t\t" << c.to_string() << endl;
  21.  
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.02s 2860KB
stdin
Standard input is empty
stdout
100		00000000000000000000000001100100
-1.48788e-05		00001000000001001000011110111001
100		10111111100101101001110000101000