fork download
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. int main() {
  5. double NaN = std::numeric_limits<double>::quiet_NaN();
  6.  
  7. bool a = (NaN != 0.0);
  8.  
  9. bool b = (NaN == 0.0);
  10. bool c = (NaN == NaN);
  11. bool d = (NaN != NaN);
  12. bool e = (NaN < 0.0);
  13.  
  14. std::cout << std::boolalpha;
  15. std::cout << "true" << std::endl;
  16. std::cout << "a = " << a << std::endl;
  17.  
  18. std::cout << "false" << std::endl;
  19. std::cout << "b = " << b << std::endl;
  20. std::cout << "c = " << c << std::endl;
  21. std::cout << "d = " << d << std::endl;
  22. std::cout << "e = " << e << std::endl;
  23. return 0;
  24. }
  25. /* end */
  26.  
  27.  
Success #stdin #stdout 0s 4228KB
stdin
Standard input is empty
stdout
true
a = true
false
b = false
c = false
d = true
e = false