This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem wirh real*8


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]