std::numeric_limits<T>:: infinity
From cppreference.net
<
cpp
|
types
|
numeric limits
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type support
| Basic types | |||||||||||||||||||||
| Fixed width integer types (C++11) | |||||||||||||||||||||
| Fixed width floating-point types (C++23) | |||||||||||||||||||||
|
|||||||||||||||||||||
| Numeric limits | |||||||||||||||||||||
| C numeric limits interface | |||||||||||||||||||||
| Runtime type information | |||||||||||||||||||||
|
|||||||||||||||||||||
std::numeric_limits
| Static constants | ||||
|
(C++11)
|
||||
| Static member functions | ||||
|
(C++11)
|
||||
|
numeric_limits::infinity
|
||||
| Helper types | ||||
|
static
T infinity
(
)
throw
(
)
;
|
(C++11 이전) | |
|
static
constexpr
T infinity
(
)
noexcept
;
|
(C++11 이후) | |
부동 소수점 타입
T
로 표현되는 특수 값 "양의 무한대"를 반환합니다.
std::
numeric_limits
<
T
>
::
has_infinity
==
true
인 경우에만 의미가 있습니다. IEEE 754(부동 소수점 숫자의 가장 일반적인 이진 표현)에서 양의 무한대는 지수부의 모든 비트가 설정되고 가수부의 모든 비트가 클리어된 값입니다.
반환값
T
|
std:: numeric_limits < T > :: infinity ( ) |
| /* 비전문화 */ | T ( ) |
| bool | false |
| char | 0 |
| signed char | 0 |
| unsigned char | 0 |
| wchar_t | 0 |
| char8_t (C++20 이후) | 0 |
| char16_t (C++11 이후) | 0 |
| char32_t (C++11 이후) | 0 |
| short | 0 |
| unsigned short | 0 |
| int | 0 |
| unsigned int | 0 |
| long | 0 |
| unsigned long | 0 |
| long long (C++11 이후) | 0 |
| unsigned long long (C++11 이후) | 0 |
| float | HUGE_VALF |
| double | HUGE_VAL |
| long double | HUGE_VALL |
예제
이 코드 실행
#include <iostream> #include <limits> int main() { double max = std::numeric_limits<double>::max(); double inf = std::numeric_limits<double>::infinity(); if (inf > max) std::cout << inf << " is greater than " << max << '\n'; }
출력:
inf is greater than 1.79769e+308
참고 항목
|
[static]
|
부동소수점 타입이 특수 값 "양의 무한대"를 표현할 수 있는지 식별합니다
(public static member constant) |