why nan is coming in c++ code example
Example 1: nan c++ example
#include <iostream>
#include <cmath>
using namespace std;
// main() section
int main()
{
double nanValue;
//generating generic NaN value
//by passing an empty string
nanValue = nan("");
//printing the value
cout<<"nanValue: "<<nanValue<<endl;
return 0;
}
Example 2: C++ is nan
doubel a = 0 ;
bool isnan_a = std::isnan(a) || std::isnan(-a);