std::numeric_limits<T>::has_infinity
From cppreference.com
| static const bool has_infinity; |
(C++11まで) | |
| static constexpr bool has_infinity; |
(C++11以降) | |
std::numeric_limits<T>::has_infinity の値は、正の無限大を別の特別な値として表現できるすべての型 T について true です。この定数はすべての浮動小数点型で意味があり、std::numeric_limits<T>::is_iec559 == true の場合は true であることが保証されます。
[編集] 標準特殊化
T
|
std::numeric_limits<T>::has_infinity の値 |
| /* 非特殊化 */ | false |
| bool | false |
| char | false |
| signed char | false |
| unsigned char | false |
| wchar_t | false |
| char8_t (C++20 以降) | false |
| char16_t (C++11 以降) | false |
| char32_t (C++11 以降) | false |
| short | false |
| unsigned short | false |
| int | false |
| unsigned int | false |
| long | false |
| unsigned long | false |
| long long (C++11 以降) | false |
| unsigned long long (C++11 以降) | false |
| float | 通常 true |
| double | 通常 true |
| long double | 通常 true |
[編集] 例
このコードを実行
#include <iostream> #include <limits> int main() { std::cout << std::boolalpha << std::numeric_limits<int>::has_infinity << '\n' << std::numeric_limits<long>::has_infinity << '\n' << std::numeric_limits<float>::has_infinity << '\n' << std::numeric_limits<double>::has_infinity << '\n'; }
実行結果の例
false false true true
[編集] 関連項目
| [static] |
与えられた浮動小数点数型の正の無限大の値を返す (public static member function) |
| [static] |
特殊な値「quiet not-a-number」(NaN) を表現できる浮動小数点数型を識別する (public static member constant) |
| [static] |
特殊な値「signaling not-a-number」(NaN) を表現できる浮動小数点数型を識別する (public static member constant) |