第一种方法:cout<<fixed<<setprecision(20)<<mydouble<<endl;
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double aDouble = 5.141592694827862736487362746374637434343434;
cout<<fixed<<setprecision(20)<<aDouble<<endl;
return 0;
}
第二种方法:cout.precision(dbl::digits);
#include <iostream>
using namespace std;
int main()
{
typedef numeric_limits< double > dbl;
double pi = 3.141592694827862736487362746374637434343434;
cout.precision(dbl::digits10);
cout << "Pi: " << fixed << pi << endl;
return 0;
}