Re: Rounding off double precision
- From: Chip Coldwell <coldwell@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 11:12:28 -0700 (PDT)
On Mar 31, 1:55 pm, Dave Seaman <dsea...@xxxxxxxxxxxx> wrote:
On Mon, 31 Mar 2008 08:15:21 -0700 (PDT), Chip Coldwell wrote:
On Mar 31, 10:34 am, Dave Seaman <dsea...@xxxxxxxxxxxx> wrote:
On Mon, 31 Mar 2008 06:55:27 -0700 (PDT), Chip Coldwell wrote:
Getting back to the OP,
parameter(Pi = 3.141592653589793238d0)creates a literal constant with the double-precision value
Not in Fortran, unless "Pi" has been typed DOUBLE PRECISION or has the
appropriate KIND. By default, the double precision constant is truncated
to type REAL.
If you add "implicit none" to the program, the compiler complains becauseSigh. The text you quoted above reads "creates a literal constant
"Pi" has not been given an explicit type.
with the double-precision value". The literal constant is
"3.141592653589793238d0" and is a double precision value. The fact
that it is being assigned to a single-precision parameter is something
different. A parameter is not a literal constant and vice-versa.
Ok, it creates an absolutely useless literal constant with a double
precision value that can't be referenced anywhere. Is that better?
The whole point of my post was that there are two ways to go wrong in
one of these parameter statements. You can assign a double precision
literal constant to a single precision named parameter:
REAL PI
PARAMETER(PI=3.141592653589793238d0)
Or, you can assign a single precision literal constant to a double
precision named parameter:
DOUBLE PRECISION PI
PARAMETER(PI=3.141592653589793238)
The result in either case is a single precision *value* stored in
either a single- or double-precision named parameter.
So I think the distinction between a literal constant and a named
parameter is relevant to the discussion.
Chip
.
- 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
- Re: Rounding off double precision
- From: glen herrmannsfeldt
- Re: Rounding off double precision
- From: Charles Coldwell
- Re: Rounding off double precision
- From: glen herrmannsfeldt
- Re: Rounding off double precision
- From: Chip Coldwell
- Re: Rounding off double precision
- From: Dave Seaman
- Re: Rounding off double precision
- From: Chip Coldwell
- Re: Rounding off double precision
- From: Dave Seaman
- Rounding off double precision
- Prev by Date: Re: Rounding off double precision
- Next by Date: Re: Call fortran in C++ project
- Previous by thread: Re: Rounding off double precision
- Next by thread: Re: Rounding off double precision
- Index(es):
Relevant Pages
|
|