This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: non-compatible round-off when printing for gfortran
- From: Tobias Burnus <burnus at net-b dot de>
- To: satyaakam goswami <satyaakam at gmail dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Fri, 20 Jul 2007 11:27:29 +0200
- Subject: Re: non-compatible round-off when printing for gfortran
- References: <6491e1350707200150r10e4c603te616906b438ec4e1@mail.gmail.com>
Hi,
satyaakam goswami wrote:
> For gfortran it outputs:
> 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3 0.3
> 0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4
and openf95 outputs the same.
> but for other compiler i tried (g77 and f77 from forte) it outputs:
> 0.2 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3
> 0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4
and g95, ifort and sunf95 have this output
whereas NAG f95 prints the same except with an extra " " at the end.
(I ignore the extra space for now.)
The difference is how the fifth value in the first row is printed:
openf95, gfortran: 0.3
others: 0.2
Ad hoc I don't see why the others print "0.2" for "0.2500000"; following
normal school maths one would round to 0.3.
The Fortran 2003 standard says this is implementation defined.
Note that Fortran 2003 allows one to specify what is done:
- RU (round up), RD (round down) (and some more) edit specifiers
- The ROUND= specifier to data transfer statements (e.g. WRITE)
- The ROUND= specifier of the OPEN statement
However, none of them are currently implemented in gfortran.
Tobias