extra odd significant digits

Hi

I am doing to I.T. support form some engineers that have some code written the problem is:

some variables are declared as double precision
for example
c_s = .4
the above show up in the watch windo as .40000000560488
all the variables wether declared as constants or calculated do this
I thought this strange but then realized

the PCs are 64bit intel and the OS is 32 bit WinXP and the fortran compiler is also 32 bit PGI fortran , will this account for the above goofyness?

0.4 is not exactly representable in floating point (perhaps a document like this one will provide more floating point reference http://docs.sun.com/source/806-3568/ncg_goldberg.html).

One thing to note is that it looks like the 0.4 is being represented as single and then stored in a double precision variable. You should get more accurate results using 0.4d0 as shown below.

[chulbert@fourier ~]$ cat fp.f90
program fp
double precision :: a,b

a = 0.4
b = 0.4d0

WRITE(*,’(f20.18 f20.18)’) a,b
end program
[chulbert@fourier ~]$ pgf90 -V

pgf90 7.2-4 64-bit target on x86-64 Linux -tp k8-64e
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2008, STMicroelectronics, Inc. All Rights Reserved.
[chulbert@fourier ~]$ pgf90 fp.f90
[chulbert@fourier ~]$ ./a.out
0.4000000059604645000.400000000000000000