Re: Rounding off double precision
- From: Bamm <bammster@xxxxxxxxx>
- Date: Sat, 29 Mar 2008 08:31:23 -0700 (PDT)
Yes! You are expecting calculations done with floating point numbers
to be EXACT. Such calculations are actually approximate. Each
operation has a small quantity of error built in. That's the nature of
floating point.
No I am not. I understand how (binary) floating points are used to
represent actual (decimal) numbers. If I thought they were exact, I
wouldn't be asking how to round it off properly so that the errors are
not shown.
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. Thus rounding off its value
to real. I realized that after studying Richard Maine's short program,
which gave me a smaller answer of 6.12303177E-17 in the expected range
of precision.
Now that I have a value in the range E-17 instead of E-06, I can now
use F15.12 to round it off! My question has been answered. Thanks to
all who helped!
.
- Follow-Ups:
- Re: Rounding off double precision
- From: glen herrmannsfeldt
- Re: Rounding off double precision
- References:
- Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Richard Maine
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: e p chandler
- Rounding off double precision
- Prev by Date: Re: Rounding off double precision
- Next by Date: Re: Rounding off double precision
- Previous by thread: Re: Rounding off double precision
- Next by thread: Re: Rounding off double precision
- Index(es):
Relevant Pages
|
|