The output stream cout allows using manipulators that you can use to set the precision directly on cout and use the fixed format specifier. To get the full precision of a double, you can use the limits library. For example,
Example
#include<iostream>
#include <limits>
using namespace std;
int main() {
// Get numeric limits of double
typedef std::numeric_limits< double > dbl;
double PI = 3.14159265358979;
cout.precision(dbl::max_digits10);
cout << "Pi: " << fixed << PI << endl;
return 0;
}Output
This will give the output −
3.14159265358979