Title
max_digits10 missing from numeric_limits
Status
cd1
Section
[numeric.special]
Submitter
Bo Persson

Created on 2006-11-20.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change and add after [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 [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 [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;
  ...
Date: 2006-11-20.00:00:00

Section [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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3216
2006-11-20 00:00:00admincreate