std::numeric_limits::digits

From cppreference.com
 
 
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
Numeric limits
C numeric limits interface
Runtime type information
Type traits
Primary type categories
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++11)
Supported operations
Relationships and property queries
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type modifications
(C++11)(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Type transformations
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type trait constants
 
 
static const int digits;
(until C++11)
static constexpr int digits;
(since C++11)

The value of std::numeric_limits<T>::digits is the number of digits in base-radix that can be represented by the type T without change. For integer types, this is the number of bits not counting the sign bit. For floating-point types, this is the number of digits in the mantissa.

[edit] Standard specializations

T value of std::numeric_limits<T>::digits
/* non-specialized */ 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
char16_t CHAR_BIT*sizeof(char16_t)
char32_t 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 CHAR_BIT*sizeof(long long)-1
unsigned long long CHAR_BIT*sizeof(long long)
float FLT_MANT_DIG
double DBL_MANT_DIG
long double LDBL_MANT_DIG

[edit] See also

[static]
the radix or integer base used by the representation of the given type
(public static member constant)
[static]
one more than the smallest negative power of the radix that is a valid normalized floating-point value
(public static member constant)
[static]
one more than the largest integer power of the radix that is a valid finite floating-point value
(public static member constant)