This is the mail archive of the gcc-help@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: double precision accuracy with g77


Bruno Merin Martin wrote:
> 
> Hello,
> 
>         I am porting a big fortran code from sun (solaris)
> to PCs running linux (much faster). I have tried the -ffloat-store
> option and some other things to get the same precision as with
> the suns but I couldn't get the programs yielding the same
> numbers up to the fifth decimal position as I need.
> 
>         I don't know how to compile and link this
> 
> #include </usr/include/fpu_control.h>
> {
>   fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
>   _FPU_SETCW(cw);
> }

If -ffloat-store doesn't help you, this won't either.

Note that there are various ways you'll get nothing better than single
precision accuracy even if you think that your program works in double
precision.

A common mistake is the following:

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      PARAMETER (PI = 3.14159265358979323846)
      ....
      RADIAN = 180.0 / PI
      ....

Because the long string of digits "defining" the constant PI isn't
suffixed with D0, the constant will be single precision, which will be
"extended to double precision" for PI, discarding all those digits
beyond the first 9.

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)


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