Re: Rounding off double precision
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 10:39:38 -0800
Bamm wrote:
(snip)
However I have since found where I went wrong. I was using
double precision Speed, Azimuth, V
Azimuth = 90.
parameter(Pi = 3.141592653589793238d0)
V = Speed * cos(Azimuth * Pi / 180.)
print *, V
The problem with the unusually large value of -4.37113886E-06 arose
because I didn't declare Pi to be double precision, even though I
assigned a double precision value to it.
This problem might be more likely to occur to ex-C programmers.
C uses #define is places where Fortran uses PARAMETER,
but #define is typeless.
It might be nice for compilers to give a warning in this case.
There are enough reasons to assign double precision values to
single precision variables that I wouldn't want a default warning
in that case. I don't believe the same is true for PARAMETER.
-- glen
.
- Follow-Ups:
- Re: Rounding off double precision
- From: Charles Coldwell
- Re: Rounding off double precision
- References:
- Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Richard Maine
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: e p chandler
- Re: Rounding off double precision
- From: Bamm
- Rounding off double precision
- Prev by Date: Re: How to Read csv Files with both Characters and Numbers?
- Next by Date: Re: F2003 standard: Can Class(*) be used in generic proogramming?
- Previous by thread: Re: Rounding off double precision
- Next by thread: Re: Rounding off double precision
- Index(es):
Relevant Pages
|
|