Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Precision Problem.

$
0
0

Hi,

I need some help please. Well I'm writing because I have a problem with the precision when I realize some simple operation or when I read some value from a file. For example in some file I must read 0.3, but Fortran reads 0.29999999999999999, that it is very close to 0.3, but it is not 0.3. On the other hand when I multiplied the same number in two different codes, I obtain different result; the unique difference is that in one code I use 1.1d0 and in the other I use 1.1. I'm working with double precision, and these problem are causing me error in my results. Then I show two codes that show the difference in accuracy (both have equal input values).

CODE Version 1:

                                DO j = 1,cp
                                        jj = cl(j,i)
                                        xx = p(jj)%x
                                        yy = p(jj)%y
                                        dx = xx - x
                                        dy = yy - y
                                        dd = DSQRT(dx**2.0d0+dy**2.0d0)
                                        IF (dd > dmax) dmax = dd
                                END DO
                                beta = 1.1d0*dmax

CODE Version 2.

        DO J=1,NPUNTOS(INOD)
          DX=X(CL(J,INOD))-XS
          DY=Y(CL(J,INOD))-YS
          DIS=SQRT(DX**2+DY**2)
          IF (dmax(inod).LT.DIS) dmax(inod)=DIS
        END DO
        BETA=dmax(inod)*1.1

Sorry for my english. and thank you in advance.

Regards.

Felipe.


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>