首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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使用%289float,,,17double%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)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com