This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g77 bug?
- To: ccpan <ccpan at mail dot ukans dot edu>
- Subject: Re: g77 bug?
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Sun, 28 Oct 2001 09:07:58 +0100
- CC: gcc-help at gcc dot gnu dot org
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <3BE734AB@webmail.ku.edu>
ccpan wrote:
> The following program compiled with g77 version 2.96 20000731 (Red Hat Linux
> 7.0) will print 3.14159274 as the answer, which is obviously wrong. Any
> suggestions?
> program test
> double precision pi
> pi = 3.141592654
> print *, pi
> stop
> end program
Unfortunately (for you) this is the correct answer according to the
Fortran standard (77, 90 and 95). 3.141592654 without any qualifier is
a single precision number, hence its accuracy cannot be better than
about 7 digits (using 32-bit floating point numbers). This matches well
with the answer you get (3.14159274). If you want a double precision
constant, write 3.141592654d0.
Hope this helps,
--
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
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)