数据类型属性C++

std::numeric_limits

<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 instantiations
fundamental arithmetic types
integral typesbool
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 typesfloat
double
long double
This template is also specialized for all  const and/or  volatile qualifications 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

membertypeproperty
is_specializedbooltrue for all arithmetic types (i.e., those for which numeric_limits is specialized).
false for all other types.
min()TMinimum finite value.
For floating types with denormalization (variable number of exponent bits): minimum positive normalized value.
Equivalent to CHAR_MINSCHAR_MINSHRT_MININT_MINLONG_MIN,LLONG_MINFLT_MINDBL_MINLDBL_MIN or 0, depending on type.
max()TMaximum finite value.
Equivalent to CHAR_MAXSCHAR_MAXUCHAR_MAXSHRT_MAXUSHRT_MAX,INT_MAXUINT_MAXLONG_MAXULONG_MAXLLONG_MAXULLONG_MAX,UINT_LEAST16_MAXUINT_LEAST32_MAXFLT_MAXDBL_MAX or LDBL_MAX, depending on type.
lowest()TMinimum finite value. (since C++11)
For integral types: the same as min().
For floating-point types: implementation-dependent; generally, the negative of max().
digitsintFor 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_DIGDBL_MANT_DIG or LDBL_MANT_DIG).
digits10intNumber of digits (in decimal base) that can be represented without change.
Equivalent to FLT_DIGDBL_DIG or LDBL_DIG for floating types.
is_signedbooltrue if type is signed.
is_integerbooltrue if type is integer.
is_exactbooltrue if type uses exact representations.
radixintFor integer types: base of the representation.
For floating types: base of the exponent of the representation (equivalent to FLT_RADIX).
epsilon()TMachine epsilon (the difference between 1 and the least value greater than 1 that is representable).
Equivalent to FLT_EPSILONDBL_EPSILON or LDBL_EPSILON for floating types.
round_error()TMeasure of the maximum rounding error.
min_exponentintMinimum negative integer value such that radix raised to (min_exponent-1)generates a normalized floating-point number.
Equivalent to FLT_MIN_EXPDBL_MIN_EXP or LDBL_MIN_EXP for floating types.
min_exponent10intMinimum negative integer value such that 10 raised to that power generates a normalized floating-point number.
Equivalent to FLT_MIN_10_EXPDBL_MIN_10_EXP or LDBL_MIN_10_EXP for floating types.
max_exponentintMaximum integer value such that radix raised to (max_exponent-1)generates a representable finite floating-point number.
Equivalent to FLT_MAX_EXPDBL_MAX_EXP or LDBL_MAX_EXP for floating types.
max_exponent10intMaximum integer value such that 10 raised to that power generates a normalized finite floating-point number.
Equivalent to FLT_MAX_10_EXPDBL_MAX_10_EXP or LDBL_MAX_10_EXP for floating types.
has_infinitybooltrue if the type has a representation for positive infinity.
has_quiet_NaNbooltrue if the type has a representation for a quiet (non-signaling) "Not-a-Number".
has_signaling_NaNbooltrue if the type has a representation for a signaling "Not-a-Number".
has_denormfloat_denorm_styleDenormalized 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_lossbooltrue if a loss of accuracy is detected as a denormalization loss, rather than an inexact result.
infinity()TRepresentation of positive infinity, if available.
quiet_NaN()TRepresentation of quiet (non-signaling) "Not-a-Number", if available.
signaling_NaN()TRepresentation of signaling "Not-a-Number", if available.
denorm_min()TMinimum positive denormalized value.
For types not allowing denormalized values: same as min().
is_iec559Ttrue if the type adheres to IEC-559 / IEEE-754 standard.
An IEC-559 type always has has_infinityhas_quiet_NaN andhas_signaling_NaN set to true; And infinityquiet_NaN andsignaling_NaN return some non-zero value.
is_boundedbooltrue if the set of values represented by the type is finite.
is_modulobooltrue if 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.
trapsbooltrue if trapping is implemented for the type.
tinyness_beforebooltrue if tinyness is detected before rounding.
round_stylefloat_round_styleRounding 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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值