Re: fast and accurate in mixed mode operations
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Thu, 10 Sep 2009 02:03:44 +0000 (UTC)
sumesh.pt <sumesh.pt@xxxxxxxxx> wrote:
< In mixed mode operations, is it advisable to convert integers to
< double using the command dble() in the expressions or would it be
< better for the compiler to do this job? I am asking this NOT from the
< point of view of understanding the program easily, but in terms of
< speed and accuracy. ie
< real*8 :: x
< integer :: i=10
< x = x/i or x=x/dble(i) which is faster and accurate.
For the same conversion, the speed and accuracy should be
the same. There are some cases where you might want a different
conversion, in which case the functions are useful.
< I am doing some kind of recursion calculations with x and hence error
< gets accumulated and I am not able to decide which is best.
If, for example, you wanted to divide a default REAL (not double
precision) by an integer, but with the division done in double
precision, then you might need a conversion function.
In Fortran 66 days DFLOAT was used to convert integer to
double precision. It seems that DBLE now will do that.
There used to be questions about constant conversion at compile
time vs. run time. That is, x/2 vs. x/2.0. I believe by now
all compilers should do that at compile time, but it used to
be a big discussion topic.
-- glen
.
- Follow-Ups:
- Re: fast and accurate in mixed mode operations
- From: robin
- Re: fast and accurate in mixed mode operations
- References:
- fast and accurate in mixed mode operations
- From: sumesh.pt
- fast and accurate in mixed mode operations
- Prev by Date: Re: fast and accurate in mixed mode operations
- Next by Date: Re: fast and accurate in mixed mode operations
- Previous by thread: Re: fast and accurate in mixed mode operations
- Next by thread: Re: fast and accurate in mixed mode operations
- Index(es):
Relevant Pages
|
Loading