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
(
)
;
|
(hasta C++11) | |
|
static
constexpr
T infinity
(
)
noexcept
;
|
(desde C++11) | |
Retorna el valor especial "infinito positivo", tal como está representado por el tipo de punto flotante
T
. Solo tiene sentido si
std::
numeric_limits
<
T
>
::
has_infinity
==
true
. En IEEE 754, la representación binaria más común de números de punto flotante, el infinito positivo es el valor con todos los bits del exponente establecidos y todos los bits de la fracción despejados.
Valor de retorno
T
|
std:: numeric_limits < T > :: infinity ( ) |
| /* no especializado */ | T ( ) |
| bool | false |
| char | 0 |
| signed char | 0 |
| unsigned char | 0 |
| wchar_t | 0 |
| char8_t (desde C++20) | 0 |
| char16_t (desde C++11) | 0 |
| char32_t (desde C++11) | 0 |
| short | 0 |
| unsigned short | 0 |
| int | 0 |
| unsigned int | 0 |
| long | 0 |
| unsigned long | 0 |
| long long (desde C++11) | 0 |
| unsigned long long (desde C++11) | 0 |
| float | HUGE_VALF |
| double | HUGE_VAL |
| long double | HUGE_VALL |
Ejemplo
#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'; }
Salida:
inf is greater than 1.79769e+308
Véase también
|
[static]
|
identifica los tipos de punto flotante que pueden representar el valor especial "infinito positivo"
(constante de miembro público estático) |