here is a post from Carlie Coats
> >
> > Hi. I am teaching a Fortran class and I was wondering...
> >
> > Is there any use for specifying kinds for constants?
>
> * YES!! *
>
> Consider that if you want a full-precision PI, then even on a
> REAL*8/REAL*16 machine (like a Cray y/C90/T90), the following
> is valid (assuming old-style free-form source, and giving an
> example which also ports to "f77") and portably illustrates an
> interesting point:
>
> DOUBLE PRECISION PI
> PARAMETER ( PI = 3.14159 26535 89793 23846 26433 83279 D0 )
>
> is OK and will get you all MIN( machine-precision, 31 ) significant
> digits; however, leave off the "D0" specifying that it is a
> double-precision constant and on an IEEE REAL*4/REAL*8 machine you have
> said "Take this constant, force it to single-precision, and then stuff
> it into double-precision parameter PI", with a net precision of 7
> digits, losing the next 10 significant digits that you almost certainly
> wanted.
>
> Carlie J. Coats, Jr. [log in to unmask]
> MCNC Environmental Programs phone: (919)248-9241
> North Carolina Supercomputing Center fax: (919)248-9245
> 3021 Cornwallis Road P. O. Box 12889
> Research Triangle Park, N. C. 27709-2889 USA
> "My opinions are my own, and I've got *lots* of them!"
>
>
-------------------
Ian
[log in to unmask]
Home page
http://www.kcl.ac.uk/kis/support/cit//fortran/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|