std::numeric_limits<T>:: infinity
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic types | |||||||||||||||||||||
| Fixed width integer types (C++11) | |||||||||||||||||||||
| Fixed width floating-point types (C++23) | |||||||||||||||||||||
|
|||||||||||||||||||||
| Numeric limits | |||||||||||||||||||||
| C numeric limits interface | |||||||||||||||||||||
| Runtime type information | |||||||||||||||||||||
|
|||||||||||||||||||||
| Static constants | ||||
|
(C++11)
|
||||
| Static member functions | ||||
|
(C++11)
|
||||
|
numeric_limits::infinity
|
||||
| Helper types | ||||
|
static
T infinity
(
)
throw
(
)
;
|
(bis C++11) | |
|
static
constexpr
T infinity
(
)
noexcept
;
|
(seit C++11) | |
Gibt den speziellen Wert "positive Unendlichkeit" zurück, wie er durch den Gleitkommatyp
T
dargestellt wird. Nur aussagekräftig, wenn
std::
numeric_limits
<
T
>
::
has_infinity
==
true
. In IEEE 754, der gebräuchlichsten binären Darstellung von Gleitkommazahlen, ist die positive Unendlichkeit der Wert, bei dem alle Bits des Exponenten gesetzt und alle Bits der Mantisse gelöscht sind.
Rückgabewert
T
|
std:: numeric_limits < T > :: infinity ( ) |
| /* nicht spezialisiert */ | T ( ) |
| bool | false |
| char | 0 |
| signed char | 0 |
| unsigned char | 0 |
| wchar_t | 0 |
| char8_t (seit C++20) | 0 |
| char16_t (seit C++11) | 0 |
| char32_t (seit C++11) | 0 |
| short | 0 |
| unsigned short | 0 |
| int | 0 |
| unsigned int | 0 |
| long | 0 |
| unsigned long | 0 |
| long long (seit C++11) | 0 |
| unsigned long long (seit C++11) | 0 |
| float | HUGE_VALF |
| double | HUGE_VAL |
| long double | HUGE_VALL |
Beispiel
#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'; }
Ausgabe:
inf is greater than 1.79769e+308
Siehe auch
|
[static]
|
identifiziert Gleitkommatypen, die den speziellen Wert "positive Unendlichkeit" darstellen können
(öffentliche statische Member-Konstante) |