Re: Rounding off double precision



Bamm wrote:
Sigh. The text you quoted above reads "creates a literal constant
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.

So how do you declare a constant in Fortran? I thought parameter was
the way constants were defined in Fortran, but if there is a better
way, I'd like to try it.

We're being exact with language here. In the statement
parameter (pi = 3.14)
3.14 is a literal constant and pi becomes a named constant. The
parameter statement gives names to literal constants.

It's an important distinction when the name and the constant have
different types or kinds. The "=" in the parameter statement
follows the same rules for type conversion as does ordinary
assignment and converts the right hand side to the type/kind
of the left (except for a special case for some character
parameters).

*** Hendrickson
.


Quantcast