This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: writing a double precission varibale with format f3.0 is not rounded


Hugo Mahr wrote:
Hello,
I realized that there is a rounding probelm:

Code:
  -> cat f0999.f
       program f0999
       double precision rdum
       rdum = 9.99999D-1
       write(*,'(F3.0)') rdum
       write(*,'(d24.6)') rdum
       end

compilation:
  -> gfortran f0999.f

execution:
  -> ./a.out
 0.
            0.999999D+00
I expect 1 as outcome instead of 0.999999d0.

With f77 that is working as expected - and this
is also according to the book fortran 95/2003 explained.
Can you please help me to clarify this.


fortran --version GNU Fortran 95 (GCC) 4.1.0 (SUSE Linux)

If you want to discuss potential bugs with compilers other than gfortran, that is off topic. What does your gfortran do? Is it a current version? In Metcalf/Reid/Cohen, I see one remark about rounding, but not enough to convince me that your example is taken from their book. I have no clue about which compiler you mean by "F77."

Here is the echo obtained with my gfortran:
$ ./a
1.
           0.999999D+00


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]