在线文档教程
C++
应用 | Utilities

std::numeric_limits::max_digits10

STD::数字[医]限制:最大限度[医]数字10

static constexpr int max_digits10(since C++11)

价值std::numeric_limits<T>::max_digits10是唯一表示该类型的所有不同值所必需的基数-10位数。T,例如序列化/反序列化为文本所必需的。这个常量对于所有浮点类型都是有意义的.

标准专业化

Tvalue of std::numeric_limits::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​
floatFLT_DECIMAL_DIG or std::ceil(std::numeric_limits<float>::digits * std::log10(2) + 1)
doubleDBL_DECIMAL_DIG orstd::ceil(std::numeric_limits<double>::digits * std::log10(2) + 1)
long doubleDECIMAL_DIG or LDBL_DECIMAL_DIG orstd::ceil(std::numeric_limits<long double>::digits * std::log10(2) + 1)

注记

与大多数数学操作不同,浮点值到文本和回文本的转换是精确性至少只要max_digits10使用%289float,,,17double%29:即使中间文本表示不精确,也保证产生相同的浮点值。它可能需要超过一百小数位数来表示float用十进制表示法。

另见

radix staticthe radix or integer base used by the representation of the given type (public static member constant)
digits staticnumber of radix digits that can be represented without change (public static member constant)
digits10 staticnumber of decimal digits that can be represented without change (public static member constant)
min_exponent staticone more than the smallest negative power of the radix that is a valid normalized floating-point value (public static member constant)
max_exponent staticone 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。

http://en.cppreference.com/w/cpp/type/NUMERIC[医]极限/最大值[医]数字10