Re: Rounding off double precision



Bamm wrote:
(snip)

However I have since found where I went wrong. I was using

double precision Speed, Azimuth, V
Azimuth = 90.
parameter(Pi = 3.141592653589793238d0)
V = Speed * cos(Azimuth * Pi / 180.)
print *, V

The problem with the unusually large value of -4.37113886E-06 arose
because I didn't declare Pi to be double precision, even though I
assigned a double precision value to it.

This problem might be more likely to occur to ex-C programmers.

C uses #define is places where Fortran uses PARAMETER,
but #define is typeless.

It might be nice for compilers to give a warning in this case.
There are enough reasons to assign double precision values to
single precision variables that I wouldn't want a default warning
in that case. I don't believe the same is true for PARAMETER.

-- glen

.



Relevant Pages

  • Re: tool to measure performance of written function
    ... >>Chris Croughton wrote: ... >>mere `double' could lose precision. ... I think I'll deal with that warning if it ever arises (many ... > programmers think that putting in casts to avoid warnings is bad anyway, ...
    (comp.lang.c)
  • Re: Question
    ... Warning test.c: 3 Assignment of int to unsigned short. ... Possible loss of precision ...
    (comp.lang.c)
  • Re: Question
    ... Warning test.c: 3 Assignment of int to unsigned short. ... Possible loss of precision ...
    (comp.lang.c)
  • Re: Errors in formula calculation
    ... >If I attempt to use precision as displayed a warning comes up that data will ... Yet it is inaccuracy of the calculation I am ...
    (microsoft.public.excel)
  • Re: Definite integral with huge variations in magnitude
    ... precision of 6 fails with warning ... accuracy after 7 recursive bisections in z near z = 0.00009765625 ...
    (sci.math.num-analysis)