Re: Precision Problem (Again...)

On Fri, 21 Sep 2007 12:58:26 +0000, Diego Signoretti wrote:

Hi all it's the first time for me on this group so please be kind...

I've got a problem with this fortran line.

VAR1 = -VAR2 * VAR3 / 2. / VAR4 * .3 / 21000000.

where all variables are REAL*8 and:

VAR2 = 1800.
VAR3 = 0.3174
VAR4 = 0.0191

well the problem is that the result is not what I expected infact:

1) the result is different from the output of a scientific calculator 2)
the result is different from the same code written in c++

Can you explain why?

A comment and a question...

The constants are single precision, try 2.0d0, 0.3d0 and 21000000.0d0, to
make them DP. Similarly, if var2, var3 and var4 are assigned by those
statements, they may or may not be 0 padded, try sticking a d0 at the end
of each of those assignments.

What do you get and what do you *expect* to get?