This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: problem wirh real*8
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Jim Wilson <wilson at specifixinc dot com>
- Cc: antonio fazzolari <antonio dot fazzolari at dlr dot de>, gcc-bugs at gcc dot gnu dot org
- Date: Thu, 20 May 2004 14:24:16 +0200
- Subject: Re: problem wirh real*8
- Organization: Moene Computational Physics, Maartensdijk, NL
- References: <40A8BE05.5010108@dlr.de> <40ABFD17.7060104@specifixinc.com>
Jim Wilson wrote:
antonio fazzolari wrote:
x=0.123456789
y=0.123456788
You have to tell the Fortran compiler that these are real*8 constants.
Otherwise, they are parsed as real constants, truncated to 32-bit
floats, and then extended to 64-bit doubles when stored into x and y.
One way to fix this is to change the two lines to
x=0.123456789d0
y=0.123456788d0
I am not a Fortran expert. There may be other or better ways to fix tihs.
Excellent reply, Jim - this is exactly what's the problem in the
original code: Floating point constants without precision attributes are
supposed to be single precision, independent on what they're assigned to.
Therefore, the outcome of printing the DOUBLE PRECISION variables x and
y shouldn't be trusted beyond the 7th digit - as exemplified by the
print-out.
[Sorry I couldn't get around earlier answering this report ]
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)