数据类型属性C++
2013-03-04 10:08
246 查看
[title2]
std::numeric_limits[/title2]
<limits>
template <class T> numeric_limits;
Numeric limits type
Provides information about the properties of arithmetic types (either integral or floating-point) in the specific platform for which the library compiles.
This class template is specialized for every fundamental arithmetic type, with its members describing the properties of type T. This template shall not be specialized for any other type.
Template instantiationsC++98
C++11
fundamental arithmetic types | |
---|---|
integral types | bool |
char | |
char16_t | |
char32_t | |
wchar_t | |
signed char | |
short int | |
int | |
long int | |
long long int | |
unsigned char | |
unsigned short int | |
unsigned int | |
unsigned long int | |
unsigned long long int | |
floating point types | float |
double | |
long double |
constand/or
volatilequalifications of these types, with the same values as their unqualified specializations.
For any other type, its default definition is used.
Members that produce a value of type T are member functions, while members of specific types are static member constants:
Members
member | type | property |
---|---|---|
is_specialized | bool | truefor all arithmetic types (i.e., those for which numeric_limits is specialized). falsefor all other types. |
min() | T | Minimum finite value. For floating types with denormalization (variable number of exponent bits): minimum positive normalized value. Equivalent to CHAR_MIN, SCHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN,LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN or 0, depending on type. |
max() | T | Maximum finite value. Equivalent to CHAR_MAX, SCHAR_MAX, UCHAR_MAX, SHRT_MAX, USHRT_MAX,INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, LLONG_MAX, ULLONG_MAX,UINT_LEAST16_MAX, UINT_LEAST32_MAX, FLT_MAX, DBL_MAX or LDBL_MAX, depending on type. |
lowest() | T | Minimum finite value. (since C++11) For integral types: the same as min(). For floating-point types: implementation-dependent; generally, the negative of max(). |
digits | int | For integer types: number of non-sign bits (radix base digits) in the representation. For floating types: number of digits (in radix base) in the mantissa (equivalent to FLT_MANT_DIG, DBL_MANT_DIG or LDBL_MANT_DIG). |
digits10 | int | Number of digits (in decimal base) that can be represented without change. Equivalent to FLT_DIG, DBL_DIG or LDBL_DIG for floating types. |
is_signed | bool | trueif type is signed. |
is_integer | bool | trueif type is integer. |
is_exact | bool | trueif type uses exact representations. |
radix | int | For integer types: base of the representation. For floating types: base of the exponent of the representation (equivalent to FLT_RADIX). |
epsilon() | T | Machine epsilon (the difference between 1 and the least value greater than 1 that is representable). Equivalent to FLT_EPSILON, DBL_EPSILON or LDBL_EPSILON for floating types. |
round_error() | T | Measure of the maximum rounding error. |
min_exponent | int | Minimum negative integer value such that radix raised to (min_exponent-1)generates a normalized floating-point number. Equivalent to FLT_MIN_EXP, DBL_MIN_EXP or LDBL_MIN_EXP for floating types. |
min_exponent10 | int | Minimum negative integer value such that 10 raised to that power generates a normalized floating-point number. Equivalent to FLT_MIN_10_EXP, DBL_MIN_10_EXP or LDBL_MIN_10_EXP for floating types. |
max_exponent | int | Maximum integer value such that radix raised to (max_exponent-1)generates a representable finite floating-point number. Equivalent to FLT_MAX_EXP, DBL_MAX_EXP or LDBL_MAX_EXP for floating types. |
max_exponent10 | int | Maximum integer value such that 10 raised to that power generates a normalized finite floating-point number. Equivalent to FLT_MAX_10_EXP, DBL_MAX_10_EXP or LDBL_MAX_10_EXP for floating types. |
has_infinity | bool | trueif the type has a representation for positive infinity. |
has_quiet_NaN | bool | trueif the type has a representation for a quiet (non-signaling) "Not-a-Number". |
has_signaling_NaN | bool | trueif the type has a representation for a signaling "Not-a-Number". |
has_denorm | float_denorm_style | Denormalized values (representations with a variable number of exponent bits). A type may have any of the following enum values: denorm_absent, if it does not allow denormalized values. denorm_present, if it allows denormalized values. denorm_indeterminate, if indeterminate at compile time. |
has_denorm_loss | bool | trueif a loss of accuracy is detected as a denormalization loss, rather than an inexact result. |
infinity() | T | Representation of positive infinity, if available. |
quiet_NaN() | T | Representation of quiet (non-signaling) "Not-a-Number", if available. |
signaling_NaN() | T | Representation of signaling "Not-a-Number", if available. |
denorm_min() | T | Minimum positive denormalized value. For types not allowing denormalized values: same as min(). |
is_iec559 | T | trueif the type adheres to IEC-559 / IEEE-754 standard. An IEC-559 type always has has_infinity, has_quiet_NaN andhas_signaling_NaN set to true; And infinity, quiet_NaN andsignaling_NaN return some non-zero value. |
is_bounded | bool | trueif the set of values represented by the type is finite. |
is_modulo | bool | trueif the type is modulo. A type is modulo if it is possible to add two positive numbers and have a result that wraps around to a third number that is less. |
traps | bool | trueif trapping is implemented for the type. |
tinyness_before | bool | trueif tinyness is detected before rounding. |
round_style | float_round_style | Rounding style. A type may have any of the following enum values: round_toward_zero, if it rounds toward zero. round_to_nearest, if it rounds to the nearest representable value. round_toward_infinity, if it rounds toward infinity. round_toward_neg_infinity, if it rounds toward negative infinity. round_indeterminate, if the rounding style is indeterminable at compile |
相关文章推荐
- C++数据类型的属性与限制
- C++数据类型的属性与限制
- java中如何遍历实体类的属性和数据类型以及属性值
- c++数据类型
- C++中各种数据类型之间的转换
- declare-styleable:自定义控件的属性 及 属性数据类型简介
- 利用反射机制动态获取对象属性名称及数据类型
- C# 与 C++ 数据类型对照表
- C++内嵌数据类型与自定义包裹类
- C#与C++数据类型比较及结构体转换(搜集整理二)
- C++基本数据类型
- c++ 与delphi 数据类型
- c++的POD数据类型
- 本地动态SQL(Open for等)如何获取SQL的定义属性,包括栏位名称和数据类型
- c++数据类型
- MySQL数据类型和常用字段属性总结
- Delphi和C++数据类型对照表
- 关于c++的数据类型范围
- C/C++基本数据类型
- C++新增数据类型long long ,unsigned long long