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: fortran help please!!!!
    ... DRIVER 3 NOV 80 ... WGS-72 PHYSICAL AND GEOPOTENTIAL CONSTANTS ... DOUBLE PRECISION EPOCH,DS50 ... There's nothing wrong w/ the Hollerith statements, it's simply a warning of an obsolescent/deleted feature but it will still function so the warnings can be ignored. ...
    (comp.lang.fortran)
  • 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)