std::numeric_limits::max_digits10
static constexpr int max_digits10 | ? | (since C++11) |
---|
价值std::numeric_limits<T>::max_digits10
是唯一表示该类型的所有不同值所必需的基数-10位数。T
,例如序列化/反序列化为文本所必需的。这个常量对于所有浮点类型都是有意义的.
标准专业化
T | value of std::numeric_limits<T>::max_digits10 |
---|---|
/* non-specialized */ | ?0? |
bool | ?0? |
char | ?0? |
signed char | ?0? |
unsigned char | ?0? |
wchar_t | ?0? |
char16_t | ?0? |
char32_t | ?0? |
short | ?0? |
unsigned short | ?0? |
int | ?0? |
unsigned int | ?0? |
long | ?0? |
unsigned long | ?0? |
long long | ?0? |
unsigned long long | ?0? |
float | FLT_DECIMAL_DIG or std::ceil(std::numeric_limits<float>::digits * std::log10(2) + 1) |
double | DBL_DECIMAL_DIG orstd::ceil(std::numeric_limits<double>::digits * std::log10(2) + 1) |
long double | DECIMAL_DIG or LDBL_DECIMAL_DIG orstd::ceil(std::numeric_limits<long double>::digits * std::log10(2) + 1) |
注记
与大多数数学操作不同,浮点值到文本和回文本的转换是精确性至少只要max_digits10
使用%289
为float
,,,17
为double
%29:即使中间文本表示不精确,也保证产生相同的浮点值。它可能需要超过一百小数位数来表示float
用十进制表示法。
另见
radix static | the radix or integer base used by the representation of the given type (public static member constant) |
---|---|
digits static | number of radix digits that can be represented without change (public static member constant) |
digits10 static | number of decimal digits that can be represented without change (public static member constant) |
min_exponent static | one more than the smallest negative power of the radix that is a valid normalized floating-point value (public static member constant) |
max_exponent static | one more than the largest integer power of the radix that is a valid finite floating-point value (public static member constant) |
? cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com