What does the C/C++-Standard guarantee about the minimum significant decimal digits of a double
?
The C++ standard actually says in a footnote of § 18.3.2.4/10 this is equivalent to DBL_DIG
as defined in the C standard. But I can't find anything about a minimum value in the C standard.
So, what is the minimum value of one of the following?
std::numeric_limits<double>::digits10
DBL_MANT_DIG
edit: No, DBL_DIG
You won't find it in the C++ standard, because C++ defers to the C standard on this one. For decimal digits, the minimum values are:
FLT_DIG 6
DBL_DIG 10
LDBL_DIG 10
So, 6 digits for float
, and 10 for double
and long double
. (This is the number of digits for which it is guaranteed that a conversion from text to the type and back will result in the same value.)
Note that DBL_MANT_DIG
corresponds to the number of digits in the base, thus usually the number of binary digits, and not the number of decimal digits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With