• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Setting precision to an output text file in C++

  • Thread starter Thread starter sandeep
  • Start date Start date
Joined
11/28/06
Messages
31
Points
18
Hi,
I am facing a problem in C++. I am trying to set the precision (for the results-matrix elements) in the output text file, which doesn't seem to be working. The command which I am using is follows:

ofstream myfile("output.txt");
myfile.precision(14);

Could anybody suggest where am I going wrong?

thanks
Sandeep
 
Hm. I've used this and it seems to have worked in the past:

outFile.precision(2);
outFile.setf(ios::fixed);
outFile.setf(ios::showpoint);
 
Back
Top