The value std::numeric_limits<double>::digits10
provides the number of decimal digits which can safely be restored, i.e., the number of decimal digits which survive a round-trip decimal->double
->decimal. Assuming more decimal digits are correct isn't helpful. If you want to faciliate the round-trip double
->decimal->double
you'd use std::numeric_limits<double>::max_digits10
.
If you want the exact values you'd use std::numeric_limits<double>::digits
but it will display numbers converted from decimal values in a funny way as they are normally rounded values. This is also the reason why max_digits10
isn't useful when presenting numbers for human consumption: the last couple of digits are normally not those expect by the human reader.