fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. vector<double> tvec;
  10. double tulorc;
  11.  
  12. tvec.push_back(2.1);
  13. tvec.push_back(3.2);
  14. tvec.push_back(NAN);
  15. tvec.push_back(712.5);
  16. tvec.push_back(500.6);
  17.  
  18. cout << "FOR test with tulorc: ";
  19. for (tulorc = 8; tulorc < 8; tulorc ++)
  20. cout << tulorc << " ";
  21. cout << "done." << endl;
  22.  
  23. for(const double& dv : tvec)
  24. {
  25. if (isnan(dv))
  26. cout << "This is not a number" << endl;
  27. else
  28. cout << dv << endl;
  29.  
  30. tulorc = dv;
  31.  
  32. if (isnan(tulorc))
  33. cout << " tulorc also is NaN" << endl;
  34. else
  35. cout << " tulorc is a number" << endl;
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
FOR test with tulorc: done.
2.1
   tulorc is a number
3.2
   tulorc is a number
This is not a number
   tulorc also is NaN
712.5
   tulorc is a number
500.6
   tulorc is a number