Hasan Karaman Hasan Karaman - 3 months ago 19
C++ Question

How do i set precision of output file?

ofstream coord("C:\\coordinates.txt");
(for loop starts here)
(things happen here)
coord << i << "," << result[i].X << "," << result[i].Y << ",0\n";
(for loop ends here)
coord.close();


ladies and gentlemen , in the output file i'm having coordinates exponential like this:

12,4.49999e+06,3.5e+06,0


how can i get rid of those exponential parts? i tried to put a "fixed" after "coord<<" in the line below but it didn't work.

coord << i << "," << result[i].X << "," << result[i].Y << ",0\n";


thanks in advance.

Answer

Use std::fixed

std::cout << std::fixed << result[i].X