C/C++ NaN constant (literal)?

后端 未结 5 876
孤独总比滥情好
孤独总比滥情好 2020-11-29 21:20

Is this possible to assign a NaN to a double or float in C/C++? Like in JavaScript you do: a = NaN. So later you can chec

5条回答
  •  感动是毒
    2020-11-29 21:59

    In C, NAN is declared in .

    In C++, std::numeric_limits::quiet_NaN() is declared in .

    But for checking whether a value is NaN, you can't compare it with another NaN value. Instead use isnan() from in C, or std::isnan() from in C++.

提交回复
热议问题