std::numeric_limits
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 在头文件 <limits> 中定义
|
||
| template< class T > class numeric_limits; |
||
numeric_limits类模板提供了一个标准化的方式来查询各种基本类型(如最大可能值类型int是std::numeric_limits<int>::max()). 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()). numeric_limits模板。标准库提供的所有基本类型的专业numeric_limits template. The standard library makes available specializations for all fundamental types:| 在头文件 <limits> 中定义
|
||
| template<> class numeric_limits<bool>; template<> class numeric_limits<char>; |
||
std::numeric_limits<const int>,std::numeric_limits<volatile int>,和std::numeric_limits<const volatile int>中所提供,并且相当于std::numeric_limits<int>.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>.目录 |
[编辑] 会员常数
| [静态的]</div></div>
|
std::numeric_limits是一家专业的标识类型 原文: identifies types for which std::numeric_limits is specialized (公共静态成员常量) |
| [静态的]</div></div>
|
识别符号类型 (公共静态成员常量) |
| [静态的]</div></div>
|
确定整数类型 (公共静态成员常量) |
| [静态的]</div></div>
|
确定确切类型 (公共静态成员常量) |
| [静态的]</div></div>
|
确定浮点类型,可以代表特殊值“正无穷大” 原文: identifies floating-point types that can represent the special value "positive infinity" (公共静态成员常量) |
| [静态的]</div></div>
|
确定浮点类型,可以代表特殊值“安静的不是一个数字”(NaN) 原文: identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) (公共静态成员常量) |
| [静态的]</div></div>
|
确定浮点类型可以代表的特殊价值“不是一个数字”(NaN)的信号 原文: identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) (公共静态成员常量) |
| [静态的]</div></div>
|
标识的非正规化的风格,所使用的浮点类型 原文: identifies the denormalization style used by the floating-point type (公共静态成员常量) |
| [静态的]</div></div>
|
identifies the floating-point types that detect loss of precision as denormalization loss rather than inexact result (公共静态成员常量) |
| [静态的]</div></div>
|
标识的舍入类型所使用的风格 原文: identifies the rounding style used by the type (公共静态成员常量) |
| [静态的]</div></div>
|
标识IEC 559/IEEE 754浮点类型的 原文: identifies the IEC 559/IEEE 754 floating-point types (公共静态成员常量) |
| [静态的]</div></div>
|
identifies types that represent a finite set of values (公共静态成员常量) |
| [静态的]</div></div>
|
识别模运算处理溢出的类型 原文: identifies types that handle overflows with modulo arithmetic (公共静态成员常量) |
| [静态的]</div></div>
|
radix数量的数字,可以表示没有变化 原文: number of radix digits that can be represented without change (公共静态成员常量) |
| [静态的]</div></div>
|
数的小数位数可以表示没有变化 原文: number of decimal digits that can be represented without change (公共静态成员常量) |
| [静态的] (C++11)</div></div>
|
数要区分这种类型的所有值的小数位数 原文: number of decimal digits necessary to differentiate all values of this type (公共静态成员常量) |
| [静态的]</div></div>
|
基数或用来表示给定类型的整数基地 原文: the radix or integer base used by the representation of the given type (公共静态成员常量) |
| [静态的]</div></div>
|
一个比最小的负电源是一个有效的标准浮点值的基数 原文: one more than the smallest negative power of the radix that is a valid normalized floating-point value (公共静态成员常量) |
| [静态的]</div></div>
|
最小的是一个有效的标准浮点值的10的负电源 原文: the smallest negative power of ten that is a valid normalized floating-point value (公共静态成员常量) |
| [静态的]</div></div>
|
一个比最大的整数次幂的基数是一个有效的有限浮点值 原文: one more than the largest integer power of the radix that is a valid finite floating-point value (公共静态成员常量) |
| [静态的]</div></div>
|
的最大整数的10次方,这是一个有效的有限浮点值 原文: the largest integer power of 10 that is a valid finite floating-point value (公共静态成员常量) |
| [静态的]</div></div>
|
标识类型,这可能会导致算术运算陷阱 原文: identifies types which can cause arithmetic operations to trap (公共静态成员常量) |
| [静态的]</div></div>
|
识别检测tinyness四舍五入前的浮点类型 原文: identifies floating-point types that detect tinyness before rounding (公共静态成员常量) |
[编辑] 成员函数
| [静态的]</div></div>
|
返回给定类型的最小的有限值 原文: returns the smallest finite value of the given type (公共静态成员函数) |
| [静态的] (C++11)</div></div>
|
返回给定类型的有限值最低 原文: returns the lowest finite value of the given type (公共静态成员函数) |
| [静态的]</div></div>
|
返回值给定类型的最大有限 原文: returns the largest finite value of the given type (公共静态成员函数) |
| [静态的]</div></div>
|
返回 1.0和下一个可表示的值给定的浮点类型之间的区别原文: returns the difference between 1.0 and the next representable value of the given floating-point type(公共静态成员函数) |
| [静态的]</div></div>
|
返回最大的舍入误差浮点型 原文: returns the maximum rounding error of the given floating-point type (公共静态成员函数) |
| [静态的]</div></div>
|
返回正无穷大值给定的浮点类型 原文: returns the positive infinity value of the given floating-point type (公共静态成员函数) |
| [静态的]</div></div>
|
返回一个安静的NaN值给定的浮点类型 原文: returns a quiet NaN value of the given floating-point type (公共静态成员函数) |
| [静态的]</div></div>
|
返回一个信号给定的浮点类型的NaN值 原文: returns a signaling NaN value of the given floating-point type (公共静态成员函数) |
| [静态的]</div></div>
|
返回值给定的浮点类型的最小正次正规 原文: returns the smallest positive subnormal value of the given floating-point type (公共静态成员函数) |
[编辑] Helper类
| 表示浮点舍入模式 原文: indicates floating-point rounding modes (枚举) | |
| 表示浮点非规范化模式 原文: indicates floating-point denormalization modes (枚举) | |
[编辑] 与C库宏常量的关系
| 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 |
[编辑] 示例
#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'; }
Possible output:
type lowest highest int -2147483648 2147483647 float -3.40282e+38 3.40282e+38 double -1.79769e+308 1.79769e+308