std::numeri...mits::digits(3)
β¨ NAME β¨
std::numeric_limits::digits β std::numeric_limits::digits (yes, bestie, the name is literally the name). This is the page from the C++ Standard Libary manual, and we are about to understand it fr fr.
π Synopsis π
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. Slay.
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). Iconic behavior, honestly.
π Standard specializations π
Okay so hereβs the list energy for the standard specializations: these are the values of std::numeric_limits<T>::digits for each T, assuming no padding bits.
/* non-specialized */β0boolβ1charβCHAR_BIT - std::numeric_limits<char>::is_signedsigned charβCHAR_BIT - 1unsigned charβCHAR_BITwchar_tβCHAR_BIT * sizeof(wchar_t) - std::numeric_limits<wchar_t>::is_signedchar8_t(since C++20) βCHAR_BITchar16_t(since C++11) βCHAR_BIT * sizeof(char16_t)char32_t(since C++11) βCHAR_BIT * sizeof(char32_t)shortβCHAR_BIT * sizeof(short) - 1unsigned shortβCHAR_BIT * sizeof(short)intβCHAR_BIT * sizeof(int) - 1unsigned intβCHAR_BIT * sizeof(int)longβCHAR_BIT * sizeof(long) - 1unsigned longβCHAR_BIT * sizeof(long)long long(since C++11) βCHAR_BIT * sizeof(long long) - 1unsigned long long(since C++11) βCHAR_BIT * sizeof(long long)floatβFLT_MANT_DIGdoubleβDBL_MANT_DIGlong doubleβLDBL_MANT_DIG
The βassuming no padding bitsβ caveat is doing important main character work here, so donβt forget it.
π See also π
radixβ the radix or integer base used by the representation of the given type;[static](public static member constant)min_exponentβ one more than the smallest negative power of the radix that is a valid normalized floating-point value;[static](public static member constant)max_exponentβ one more than the largest integer power of the radix that is a valid finite floating-point value;[static](public static member constant)
Source/version and date tea: this page comes from http://cppreference.com, dated 2024.06.10, and its footer name is std::numeri...mits::digits(3). Periodt, thatβs the whole page, and you ate it up π«Άπβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms