How to generate NaN float value in C++

2 Answers

0 votes
#include <iostream>
#include <cmath>

int main()
{
    float f;
    
    f = nanf("");
    
    std::cout << f;
}




/*
run:

nan

*/

 



answered Jul 30, 2022 by avibootz
0 votes
#include <iostream>
#include <cmath>

int main()
{
    float f = NAN;
    
    std::cout << f;
}




/*
run:

nan

*/

 



answered Jul 30, 2022 by avibootz

Related questions

...