By referring to
How do I print a double value with full precision using cout?
and
What is the meaning of numeric_limits<double>::digits10
I am slightly confused.
Shall I used :
ss.precision(std::numeric_limits<double>::digits10);
or
ss.precision(std::numeric_limits<double>::digits10 + 2);
to get maximum double precision?
it depend on number of “decimal component” you have in data.
std::numeric_limits::digits10 will give the maximum number of “floating component”
ios_base::precision specifies the number of digits (decimal + float components) to display.
if your decimal component is always less than 100 (-99 to 99), code below always give maximum precision.