Joined: 01 Dec 2005
|Posted: Thu Aug 21, 2008 4:02 am Post subject:
|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
double precision :: a,b
a = 0.4
b = 0.4d0
WRITE(*,'(f20.18 f20.18)') a,b
[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