LoginSignup
3
3

More than 5 years have passed since last update.

C++でのNANの定義とNANチェック

Last updated at Posted at 2015-01-25
#include <limits>

//float n = 0 / 0.f; //バッドノウハウ。コンパイラー依存で、特にWinとかではビルドエラー
float n = numeric_limits<float>::quiet_NaN();

if(isnan(n)) {
  cout << "is NAN." << endl;
} else {
  cout << "is not NAN." << endl;
}

[参考URL]

NANの定義について
http://d.hatena.ne.jp/pyopyopyo/20100330/p1

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3