std::numeric_limits<T>::digits

From cppreference.com
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Type support
Basic types
Fixed width integer types (哋它亢++11)
Fixed width floating-point types (哋它亢++23)
(哋它亢++11)    
(哋它亢++17)
(哋它亢++11)

Numeric limits
C numeric limits interface
Runtime type information
(哋它亢++11)
 
 
static const int digits;
(until 哋它亢++11)
static constexpr int digits;
(since 哋它亢++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 and the padding bits (if any). For floating-point types, this is the digits of the mantissa (for IEC 559/IEEE 754 implementations, this is the number of digits stored for the mantissa plus one, because the mantissa has an implicit leading 1 and binary point).

Standard specializations

T value of std::numeric_limits<T>::digits
(assuming no padding bits)
/* 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

char8_t (since 哋它亢++20) CHAR_BIT
char16_t (since 哋它亢++11) CHAR_BIT * sizeof(char16_t)
char32_t (since 哋它亢++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 (since 哋它亢++11) CHAR_BIT * sizeof(long long) - 1
unsigned long long (since 哋它亢++11) CHAR_BIT * sizeof(long long)
float FLT_MANT_DIG
double DBL_MANT_DIG
long double LDBL_MANT_DIG

See also

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