CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Scalar precision: float vs. double (

Hisham August 25, 2011 09:35

Scalar precision: float vs. double

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

FelixL August 25, 2011 09:51

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


Hisham August 25, 2011 09:56

I use the following


#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:


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:


writePrecision 15;

All times are GMT -4. The time now is 08:02.