Re: Rounding off double precision
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Sat, 29 Mar 2008 15:01:16 GMT
Bamm wrote:
Probably not, different compilers print out a different numberwhen 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?
of digits for list directed output. The standard doesn't
specify how many digits to print out for an * format. If
you want to experiment, try an explicit format.
double precision T
real R
T = COS(90 * 3.141592653589793238d0 / 180.)
R = T
write (*, '(E20.15)' ) T, R
write (*, '(F10.5)' ) T, R
end
Try different format widths (the 10 or 20) and number of digits
(the 5 or 15) until you get something you like.
Also, it's not obvious, but for output, double precision values
are printed with an E exponent when you use the E edit descriptor.
You could try using D20.15. Some processors print this with a D
exponent, others use an E.
*** Hendrickson
.
- 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: F2003 standard: Can Class(*) be used in generic proogramming?
- 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):