There are a number of red herrings in your questions, but the key point is that computers do their arithmetic and representation of numbers in binary rather than decimal, so while 1.1 may appear to you to be a number that can be represented exactly, to the computer it is a number whose representation is a repeating fraction, analogous to 1 and 1/7 being 1.142857142857... in decimal. For any given number of binary digits, the computer can use the closest number it has to 1.1 using that number of digits, but it willnot be exact.

In the first code sequence, you used 1.1d0, which a double precision constant, about as precise as using 1.142857142857143 for 1 and 1/7. Inthe second sequence, you used 1.1, which is a single precision constant, only about as precise as using 1.142857 for 1 and 1/7. Thus, it should come as no surprise that the first sequence gives better results.

If your variables are declared double precision, 1.1 will be converted to a double precision value, but unfortunately this is like converting 1.142857 to 1.142857000000000. It may be a double precision value, but isn't the double precision value you would want for best double precision results.

## Precision Problem.

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.