Re: fast and accurate in mixed mode operations



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
.



Relevant Pages

  • Re: fast and accurate in mixed mode operations
    ... | conversion, in which case the functions are useful. ... | precision, then you might need a conversion function. ... You WOULD need to use a conversion function (viz, DBLE ... | There used to be questions about constant conversion at compile ...
    (comp.lang.fortran)
  • Re: WG: SI Units - has Ada missed the boat?
    ... I don't remember the details but there was also a way to define the conversion from various units into the generic _UNITS. ... This program would then write the ADA specs and bodies for the conversion. ... The "UNITS" package took about 4 hours to compile and every component took a long time to compile because every expression had to be compared to the myriad of overloads to determine if the expression was valid. ... myint: INTEGER; ...
    (comp.lang.ada)
  • Re: Microsoft Losing Interest in C#?
    ... > The code doesn't compile right now because, IIRC, the JCLA generated a few ... > javaisms in the sections where a direct conversion wasn't possible. ... The JLCA doesn't understand the Comparable interface, ... UUID.cs: error CS0246: The type or namespace name 'MessageFormat' ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [ANNOUNCE] high-res-timers patches for 2.6.6
    ... but all are compile in. ... >>I would have to redo the conversion code. ... can, at boot time, switch to one of the standard clocks and thus disable HRT (or ... I had not considered not using the APIC timer if it was available. ...
    (Linux-Kernel)
  • 50 years of progress in the language
    ... almost every program would compile and run correctly using ... Smaller length alphabetic test onstant strings were treated as ... Conversion between integer variabless and equivalent digit strings ... the character array and the character string. ...
    (comp.lang.fortran)

Loading