Faken Faken - 2 months ago 15
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

Use the setprecision() manipulator:

http://www.cplusplus.com/reference/iostream/manipulators/setprecision/

You can also force scientific notation with the scientific manipulator:

http://www.cplusplus.com/reference/iostream/manipulators/scientific/

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