This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
Section: 17.3.5.3 [numeric.special] Status: CD1 Submitter: Bo Persson Opened: 2006年11月20日 Last modified: 2016年01月28日
Priority: Not Prioritized
View all other issues in [numeric.special].
View all issues with CD1 status.
Discussion:
Section 17.3.5.3 [numeric.special] starts out by saying that "All members shall be provided for all specializations."
Then it goes on to show specializations for float and bool, where one member is missing (max_digits10).
Maarten Kronenburg adds:
I agree, just adding the comment that the exact number of decimal digits is digits * ln(radix) / ln(10), where probably this real number is rounded downward for digits10, and rounded upward for max_digits10 (when radix=10, then digits10=max_digits10). Why not add this exact definition also to the standard, so the user knows what these numbers exactly mean.
Howard adds:
For reference, here are the correct formulas from N1822:
digits10 = floor((digits-1) * log10(2)) max_digits10 = ceil((1 + digits) * log10(2))
We are also missing a statement regarding for what specializations this member has meaning.
Proposed resolution:
Change and add after 17.3.5.2 [numeric.limits.members], p11:
static const int max_digits10;-11- Number of base 10 digits required to ensure that values which differ
(削除) by only one epsilon (削除ここまで)are always differentiated.(追記) -12- Meaningful for all floating point types. (追記ここまで)
Change 17.3.5.3 [numeric.special], p2:
template<> class numeric_limits<float> {
public:
static const bool is_specialized = true;
...
static const int digits10 = 6;
(追記) static const int max_digits10 = 9 (追記ここまで);
...
Change 17.3.5.3 [numeric.special], p3:
template<> class numeric_limits<bool> {
public:
static const bool is_specialized = true;
...
static const int digits10 = 0;
(追記) static const int max_digits10 = 0 (追記ここまで);
...