Phillip Helbig writes:
> > real( double_k) :: pi = 3.1415926_double_k
> >
> > The "_double_k" on the literal is necessary
> > to get a double_k value. Otherwise, it's
> > a default real value, which may not be double_k.
>
> If it weren't for the restriction on initialisation expressions, one
> could write dble(3.1415926).
>
> Of course, if you are using such precision, you probably want to include
> more places.
*NO*. This will *NOT* get you a value better than single precision.
There is no real rocket science here. The constant 3.1415926 (even
with more digits) is a single precision constant. If it has a
"d0" or a "_some_kind_number" on the end, then it may be a different
kind. But just writing it as an argument of a function does not
do so. The intrinsic dble has no magic properties here - it's just
like any other function in this regard. It takes its arguments
and computes a result value based on them. It does *NOT* look at
its arguments and decide that they really should have had some
other values.
Dble will convert its argument to a double precision format,
as will the REAL intrinsic with an appropriate kind, but this will
not magically make its argument more precise. Once you have
expressed 3.1415926 as a single precision value, any extra precision
is lost, never to bee seen again. There is no function to fix it
up after the fact.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|