Faken Faken - 10 months ago 47
C++ Question

How do I display more decimals in the output console?

I want to output the value of a double in it's full precision. However, when using the cout function, it only displays the first 6 digits even though there is around 15-16 digits of precision.

How do I get my program to display the entire value, including the magnitude (power) component?

Answer Source

Use the setprecision() manipulator:


You can also force scientific notation with the scientific manipulator:


cout << scientific << setprecision(15) << my_number << endl;