CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Info(messageStream) - Specifying the Precision (http://www.cfd-online.com/Forums/openfoam-programming-development/121723-info-messagestream-specifying-precision.html)

HakikiCanakkaleli August 4, 2013 08:47

Info(messageStream) - Specifying the Precision
 
Hi,

== 1 ==

Is it possible to specify the precision of an output number which is, say, a variable type of doubleScalar with Info in OpenFOAM?

== 2 ==
For example:

Code:

doubleScalar variable = 2.0000000001;
Info << "variable: " << variable << endl;

== 3 ==
In another thread, the following was given once:

Quote:

Originally Posted by akidess (Post 325171)
printf is pure C, it's C++ descendant is cout. Assuming Info is built upon cout, you can do:

Code:

Info << setw(7);
Info.precision(3);
Info <<  fixed    << a << '\t' << b << '\t' << c << endl;

Try it.

However, it does not work as confirmed by another reader as well.

== 4 ==

Many thanks for any help.

HakikiCanakkaleli August 14, 2013 14:25

The answer that I found is that:

Code:

#include "IOmanip.H"

...

Info << setprecision(10);
Info << " i " << xx << endl;

...

Simply, identical to that of C++ standard, had forgotten the header file.

mkraposhin August 14, 2013 14:36

google: format with cout


All times are GMT -4. The time now is 06:27.