The following code:
double x = 3.14;
double y = 3.14159265359;
cout<<fixed<<setprecision(6)<<x<<", "<<y<<endl;
prints: 3.140000, 3.141593
I want to print values without unnecessary zeros: 3.14, 3.141593 How to do that without using the string and stringstream classes ?