CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Scalar precision: float vs. double (https://www.cfd-online.com/Forums/openfoam-programming-development/91886-scalar-precision-float-vs-double.html)

Hisham August 25, 2011 09:35

Scalar precision: float vs. double
 
Hi

I use scalars to solve a (simple closed form) quadratic equation. Nevertheless, they always give a 6 digits precision (a float). I tried to declare the scalars as doubleScalar instead of just scalar. However, the result is still in 6 digits. I made sure that the solution can be more precise http://www.mathsisfun.com/quadratic-...on-solver.html

FelixL August 25, 2011 09:51

This is probably an output related issue.
How are you printing out your results?


Greetings,
Felix

Hisham August 25, 2011 09:56

I use the following

Quote:

#include "IOstreams.H"
using namespace Foam

Info << scalar;

Hisham August 25, 2011 10:24

Thanks for the tip. I guess it is an output issue. So using "cout" one can use:

Quote:

cout.precision(15);
Is there a possible way around for "Info" just for debugging sake. Anyway thanks a lot for quick answer.

Vielen Dank nochmal :D

marupio August 25, 2011 11:09

There's a couple of precision options in the controlDict. One is for the time directory name, and the other is for the output. Can't remember what they are off-hand, but they should be easy to find.

Hisham August 25, 2011 11:24

Hi marupio

Thanks a lot, I found it:

Quote:

writePrecision 15;


All times are GMT -4. The time now is 05:56.