最終更新日時(UTC):
が更新

履歴 編集

variable
<limits>

std::numeric_limits::has_quiet_NaN

// C++03
static const bool has_quiet_NaN;

// C++11
static constexpr bool has_quiet_NaN;

概要

浮動小数点数型において、型Tがシグナルを投げないNaN (Not a Number)を持っているかを判定。
is_iec559 != falseが成り立つ場合は常にtrueである。

numeric_limits<float>::has_quiet_NaNtrueのときマクロNANがdefineされ、そうでないときはdefineされない。

#include <iostream>
#include <limits>

int main()
{
  constexpr bool a = std::numeric_limits<int>::has_quiet_NaN;
  constexpr bool b = std::numeric_limits<float>::has_quiet_NaN;
  constexpr bool c = std::numeric_limits<double>::has_quiet_NaN;

  std::cout << std::boolalpha;
  std::cout << "int : " << a << std::endl;
  std::cout << "float : " << b << std::endl;
  std::cout << "double : " << c << std::endl;
}

出力

int : false
float : true
double : true