fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <bitset>
  4.  
  5. std::string PrintBinary(float val)
  6. {
  7. std::bitset<32> bits(*reinterpret_cast<int *>(&val));
  8. return bits.to_string();
  9. }
  10.  
  11. int main ()
  12. {
  13. double b = 0.0;
  14. float a = - (float) b;
  15.  
  16. std::cout << PrintBinary(a) << std::endl;
  17. printf("a == %.2f %s 0\n", a, a == 0 ? "==": "!=");
  18. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
10000000000000000000000000000000
a == -0.00 == 0