Re: Rounding off double precision
- From: e p chandler <epc8@xxxxxxxx>
- Date: Fri, 28 Mar 2008 22:10:40 -0700 (PDT)
On Mar 29, 12:48 am, Bamm <bamms...@xxxxxxxxx> wrote:
when I run the complete program
write (*,*) COS(90 * 3.141592653589793238d0 / 180.)
end
using g95 on this Mac, I get
6.123256244561421E-17
which is about the expected accuracy for double precision.
Here's the answer I get for the same program above using g77 on Linux:
6.12303177E-17
Am I doing anything wrong?
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.
To start with, you can not represent the EXACT value of PI with a
finite number of bits. It only gets worse from there. :-).
- e
.
- Follow-Ups:
- Re: Rounding off double precision
- From: Bamm
- 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
- Rounding off double precision
- Prev by Date: Re: Rounding off double precision
- Next by Date: Re: F2003 standard: Can Class(*) be used in generic proogramming?
- Previous by thread: Re: Rounding off double precision
- Next by thread: Re: Rounding off double precision
- Index(es):
Relevant Pages
|
|