std::numeric_limits<T>::digits
来自 cppreference.cn
static const int digits; |
(C++11 前) | |
static constexpr int digits; |
(C++11 起) | |
std::numeric_limits<T>::digits 的值表示类型 T
在以 radix 为基数时,可以不变地表示的数字位数。对于整数类型,这是不计符号位和填充位(如果有)的位数。对于浮点类型,这是尾数的位数(对于 IEC 559/IEEE 754 实现,这是为尾数存储的位数加一,因为尾数有一个隐式的前导 1 和二进制小数点)。
[edit] 标准特化
T
|
std::numeric_limits<T>::digits 的值 (假设没有填充位) |
/* 未特化 */ | 0 |
bool | 1 |
char | CHAR_BIT - std::numeric_limits<char>::is_signed |
signed char | CHAR_BIT - 1 |
unsigned char | CHAR_BIT |
wchar_t | CHAR_BIT * sizeof(wchar_t) - std::numeric_limits<wchar_t>::is_signed |
char8_t (C++20起) | CHAR_BIT |
char16_t (C++11起) | CHAR_BIT * sizeof(char16_t) |
char32_t (C++11起) | CHAR_BIT * sizeof(char32_t) |
short | CHAR_BIT * sizeof(short) - 1 |
unsigned short | CHAR_BIT * sizeof(short) |
int | CHAR_BIT * sizeof(int) - 1 |
unsigned int | CHAR_BIT * sizeof(int) |
long | CHAR_BIT * sizeof(long) - 1 |
unsigned long | CHAR_BIT * sizeof(long) |
long long (C++11起) | CHAR_BIT * sizeof(long long) - 1 |
unsigned long long (C++11起) | CHAR_BIT * sizeof(long long) |
float | FLT_MANT_DIG |
double | DBL_MANT_DIG |
long double | LDBL_MANT_DIG |
[edit] 参见
[静态] |
给定类型的表示所用的基或整数底 (public static member constant) |
[静态] |
比最小负数基幂大一,该基幂是有效的正规化浮点值 (public static member constant) |
[静态] |
比最大整数基幂大一,该基幂是有效的有限浮点值 (public static member constant) |