std::numeric_limits<T>::has_infinity
From ko.cppreference.net
static const bool has_infinity;
|
(until C++11) | |
static constexpr bool has_infinity;
|
(since C++11) | |
The value of std::numeric_limits<T>::has_infinity is true for all types T capable of representing the positive infinity as a distinct special value. This constant is meaningful for all floating-point types and is guaranteed to be true if std::numeric_limits<T>::is_iec559 == true.
표준 특수화
T
|
std:: numeric_limits < T > :: has_infinity 의 값 |
| /* non-specialized */ | 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) |