std::numeric_limits - cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Definido no cabeçalho <limits> |
||
|
|
||
O modelo de classe numeric_limits fornece uma maneira padronizada para consultar várias propriedades de tipos fundamentais (por exemplo, o maior valor possível para o tipo int é std::numeric_limits<int>::max()).
Original:
The numeric_limits class template provides a standardized way to query various properties of fundamental types (e.g. the largest possible value for type int is std::numeric_limits<int>::max()).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esta informação é fornecida através de especializações do molde numeric_limits. A biblioteca padrão faz especializações disponíveis para todos os tipos fundamentais:
Original:
This information is provided via specializations of the numeric_limits template. The standard library makes available specializations for all fundamental types:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
<tbody> </tbody>
| Definido no cabeçalho <limits> |
||
|
|
||
Além disso, existe uma especialização para cada versão cv qualificado de cada tipo fundamental, idêntica à especialização sem ressalvas, por exemplo, std::numeric_limits<const int>, std::numeric_limits<volatile int> e std::numeric_limits<const volatile int> são fornecidos e são equivalentes ao std::numeric_limits<int>.
Original:
Additionally, a specialization exists for every cv-qualified version of each fundamental type, identical to the unqualified specialization, e.g. std::numeric_limits<const int>, std::numeric_limits<volatile int>, and std::numeric_limits<const volatile int> are provided and are equivalent to std::numeric_limits<int>.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O padrão de tipos de bibliotecas que são aliases de tipos fundamentais (como std::size_t ou std::streamsize também pode ser examinado com as características de tipo std::numeric_limits.
Original:
The standard library types that are aliases of fundamental types (such as std::size_t or std::streamsize may also be examined with the std::numeric_limits type traits.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Implementações podem fornecer especializações de std::numeric_limits para implementação tipos específicos: por exemplo. GCC. Fornece std::numeric_limits<__int128> bibliotecas podem adicionar especializações para biblioteca fornecidos tipos, por exemplo, dispõe OpenEXR std::numeric_limits<half> para um 16-bit tipo de ponto flutuante.
Original:
Implementations may provide specializations of std::numeric_limits for implementation-specific types: e.g. GCC provides std::numeric_limits<__int128>. Libraries may add specializations for library-provided types, e.g. OpenEXR provides std::numeric_limits<half> for a 16-bit floating-point type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Constantes de membros
[estática] |
identifica os tipos para que std::numeric_limits se especializou Original: identifies types for which std::numeric_limits is specialized The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica os tipos assinados Original: identifies signed types The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica os tipos inteiros Original: identifies integer types The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica os tipos de exatas Original: identifies exact types The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica tipos de ponto flutuante que pode representar o valor especial "infinito positivo" Original: identifies floating-point types that can represent the special value "positive infinity" The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica tipos de ponto flutuante que podem representar o valor especial "tranquila, não-número um" (NaN) Original: identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica tipos de ponto flutuante que podem representar o valor especial "de sinalização não-número um" (NaN) Original: identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica o estilo desnormalização usado pelo tipo de ponto flutuante Original: identifies the denormalization style used by the floating-point type The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifies the floating-point types that detect loss of precision as denormalization loss rather than inexact result (membro estático público constante) [edit] |
[estática] |
identifica o estilo arredondamento usado pelo tipo Original: identifies the rounding style used by the type The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica os IEC 559/IEEE 754 tipos de ponto flutuante Original: identifies the IEC 559/IEEE 754 floating-point types The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifies types that represent a finite set of values (membro estático público constante) [edit] |
[estática] |
identifica os tipos que lidam com transborda com a aritmética módulo Original: identifies types that handle overflows with modulo arithmetic The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
número de dígitos Original: number of The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
número de dígitos decimais que podem ser representadas sem alterações Original: number of decimal digits that can be represented without change The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] (C++11) |
número de dígitos decimais necessários para diferenciar os valores deste tipo Original: number of decimal digits necessary to differentiate all values of this type The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
a raiz ou base inteiro usado pela representação do tipo de dado Original: the radix or integer base used by the representation of the given type The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
mais um do que o menor poder negativo do radix que é um valor válido de ponto flutuante normalizado Original: one more than the smallest negative power of the radix that is a valid normalized floating-point value The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
a menor potência negativa de 10 que é um valor válido de ponto flutuante normalizado Original: the smallest negative power of ten that is a valid normalized floating-point value The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
um a mais que o maior poder inteiro da raiz que é um valor válido de ponto flutuante finita Original: one more than the largest integer power of the radix that is a valid finite floating-point value The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
a maior potência inteira de 10 que é um válido valor de ponto flutuante finita Original: the largest integer power of 10 that is a valid finite floating-point value The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica os tipos que podem causar operações aritméticas para prender Original: identifies types which can cause arithmetic operations to trap The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
[estática] |
identifica tipos de ponto flutuante que detectam tinyness antes de arredondamentos Original: identifies floating-point types that detect tinyness before rounding The text has been machine-translated via Google Translate. (membro estático público constante) [edit] |
Funções de membro
[estática] |
retorna o menor valor finito do tipo de dado Original: returns the smallest finite value of the given type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] (C++11) |
retorna o menor valor finito do tipo de dado Original: returns the lowest finite value of the given type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna o maior valor finito do tipo de dado Original: returns the largest finite value of the given type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna a diferença entre Original: returns the difference between The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna o erro de arredondamento máximo do dado tipo de ponto flutuante Original: returns the maximum rounding error of the given floating-point type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna o valor infinito positivo do dado tipo de ponto flutuante Original: returns the positive infinity value of the given floating-point type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna um valor NaN tranquila do determinado tipo de ponto flutuante Original: returns a quiet NaN value of the given floating-point type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna um valor NaN sinalização do dado tipo de ponto flutuante Original: returns a signaling NaN value of the given floating-point type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
[estática] |
retorna o menor valor positivo subnormal do dado tipo de ponto flutuante Original: returns the smallest positive subnormal value of the given floating-point type The text has been machine-translated via Google Translate. (função public static membro) [edit] |
Classes auxiliares
indica os modos de ponto flutuante de arredondamento Original: indicates floating-point rounding modes The text has been machine-translated via Google Translate. (enum) [edit] | |
indica os modos de ponto flutuante desnormalização Original: indicates floating-point denormalization modes The text has been machine-translated via Google Translate. (enum) [edit] | |
Relacionamento com constantes C biblioteca de macro
| Specialization | Members | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
min()
|
lowest()(C++11) |
max()
|
epsilon()
|
digits
|
digits10
|
min_exponent
|
min_exponent10
|
max_exponent
|
max_exponent10
|
radix
| |
numeric_limits< bool >
|
2
| ||||||||||
numeric_limits< char >
|
CHAR_MIN | CHAR_MIN | CHAR_MAX | 2
| |||||||
numeric_limits< signed char >
|
SCHAR_MIN | SCHAR_MIN | SCHAR_MAX | 2
| |||||||
numeric_limits< unsigned char >
|
0
|
0
|
UCHAR_MAX | 2
| |||||||
numeric_limits< wchar_t >
|
WCHAR_MIN | WCHAR_MIN | WCHAR_MAX | 2
| |||||||
numeric_limits< char16_t >
|
0
|
0
|
UINT_LEAST16_MAX | 2
| |||||||
numeric_limits< char32_t >
|
0
|
0
|
UINT_LEAST32_MAX | 2
| |||||||
numeric_limits< short >
|
SHRT_MIN | SHRT_MIN | SHRT_MAX | 2
| |||||||
numeric_limits< signed short >
|
|||||||||||
numeric_limits< unsigned short >
|
0
|
0
|
USHRT_MAX | 2
| |||||||
numeric_limits< int >
|
INT_MIN | INT_MIN | INT_MAX | 2
| |||||||
numeric_limits< signed int >
|
|||||||||||
numeric_limits< unsigned int >
|
0
|
0
|
UINT_MAX | 2
| |||||||
numeric_limits< long >
|
LONG_MIN | LONG_MIN | LONG_MAX | 2
| |||||||
numeric_limits< signed long >
|
|||||||||||
numeric_limits< unsigned long >
|
0
|
0
|
ULONG_MAX | 2
| |||||||
numeric_limits< long long >
|
LLONG_MIN | LLONG_MIN | LLONG_MAX | 2
| |||||||
numeric_limits< signed long long >
|
|||||||||||
numeric_limits< unsigned long long >
|
0
|
0
|
ULLONG_MAX | 2
| |||||||
numeric_limits< float >
|
FLT_MIN | -FLT_MAX
|
FLT_MAX | FLT_EPSILON | FLT_MANT_DIG | FLT_DIG | FLT_MIN_EXP | FLT_MIN_10_EXP | FLT_MAX_EXP | FLT_MAX_10_EXP | FLT_RADIX |
numeric_limits< double >
|
DBL_MIN | -DBL_MAX
|
DBL_MAX | DBL_EPSILON | DBL_MANT_DIG | DBL_DIG | DBL_MIN_EXP | DBL_MIN_10_EXP | DBL_MAX_EXP | DBL_MAX_10_EXP | FLT_RADIX |
numeric_limits< long double >
|
LDBL_MIN | -LDBL_MAX
|
LDBL_MAX | LDBL_EPSILON | LDBL_MANT_DIG | LDBL_DIG | LDBL_MIN_EXP | LDBL_MIN_10_EXP | LDBL_MAX_EXP | LDBL_MAX_10_EXP | FLT_RADIX |
Exemplo
#include <limits> #include <iostream> int main() { std::cout << "type\tlowest\thighest\n"; std::cout << "int\t" << std::numeric_limits<int>::lowest() << '\t' << std::numeric_limits<int>::max() << '\n'; std::cout << "float\t" << std::numeric_limits<float>::lowest() << '\t' << std::numeric_limits<float>::max() << '\n'; std::cout << "double\t" << std::numeric_limits<double>::lowest() << '\t' << std::numeric_limits<double>::max() << '\n'; }
Potencial saída:
type lowest highest int -2147483648 2147483647 float -3.40282e+38 3.40282e+38 double -1.79769e+308 1.79769e+308