6

I have the following code:

std::ofstream myfile;
std::stringstream filename3;
myfile.open("results.txt");

myfile << "precision= " << precision << "\n";

And the output in my file is formatted like this:

precision= 5.96e-07...

How can I print the numeric value as a number instead of a numeric value expressed using e?

jrok
  • 54,456
  • 9
  • 109
  • 141
obelix
  • 880
  • 2
  • 16
  • 43

1 Answers1

12

Use stream manipulator fixed:

myfile << "precision= " << std::fixed << precision << "\n";

You might also want to use setprecision to adjust the number of decimal digits.

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
jrok
  • 54,456
  • 9
  • 109
  • 141