On 4/26/13 2:45 AM, Phillip Helbig wrote:
>> What is the modern recommended way of working with double precision numbers?
>
> There is a huge amount of discussion on this, both here and in
> comp.lang.fortran, as well as various books.
>
> Why not just use DOUBLE PRECISION?
>
> It depends on what you want, of course. If you want to specify an exact
> minimum precision and handle the cases when it is not available then,
> yes, there are tools for this, such as:
>
>> integer, parameter :: dp = selected_real_kind(p=precision(0.0)+1)
>>
>> which on all computers that I tried gives double precision.
>
>
> But if you want double precision, just write DOUBLE PRECISION.
The problem is that, in terms of precision, DOUBLE PRECISION is
meaningless. It might be 64-bit IEEE, or it might be 128-bit IEEE. Or
possibly something else. That's why the mechanisms for specifying
precision were added. In fact, I would say that a Fortran programming
"best practice" is to NEVER declare something DOUBLE PRECISION. At least
for new codes that are not tied to last-century libraries that have
DOUBLE PRECISION argument or function result declarations.
Cheers,
Bill
--
Bill Long [log in to unmask]
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
|