Actually + and - .01 print as zero - [dir:~/tests/gfortran] dir% gfortran -o print01 print01.f [dir:~/tests/gfortran] dir% print01 0.00 0.00 STOP 0 [dir:~/tests/gfortran] dir% cat print01.f program main x=-.01 y=.01 write(6,1000)x,y stop 1000 format (2f10.2) end
Confirmed.
$ cat pr20124.f x = -.01 y = .01 write(*,'(2f10.2)') x, y print *, x, y end $ ./bin/gfortran -static pr20124.f && ./a.out 0.00 0.00 -9.9999998E-03 9.9999998E-03 It looks like we're not handling the rounding correctly in this case (if you try with x=-0.05, which can be represented in a real exactly, it doesn't happen).
Patch proposed in http://gcc.gnu.org/ml/fortran/2005-02/msg00315.html
Subject: Bug 20124 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: bdavis@gcc.gnu.org 2005-03-11 08:02:46 Modified files: libgfortran/io : write.c libgfortran : ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: pr20124.f90 Log message: 2005-03-12 Francois-Xavier Coudert <coudert@clipper.ens.fr> PR libfortran/20124 * gfortran.dg/pr20124.f90: New Test 2005-03-11 Francois-Xavier Coudert <coudert@clipper.ens.fr> PR libfortran/20124 * write.c (output_float): Adds a nzero_real variable to store the number of leading zeros whatever the format width is. Corrects the rounding of numbers less than 10^(-width). Fixes typo in an error message. Updates copyright years Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23.2.2&r2=1.23.2.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.3&r2=1.163.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.36&r2=1.5084.2.37 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20124.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 20124 CVSROOT: /cvs/gcc Module name: gcc Changes by: bdavis@gcc.gnu.org 2005-03-11 08:03:03 Modified files: libgfortran/io : write.c libgfortran : ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: pr20124.f90 Log message: 2005-03-12 Francois-Xavier Coudert <coudert@clipper.ens.fr> PR libfortran/20124 * gfortran.dg/pr20124.f90: New Test 2005-03-11 Francois-Xavier Coudert <coudert@clipper.ens.fr> PR libfortran/20124 * write.c (output_float): Adds a nzero_real variable to store the number of leading zeros whatever the format width is. Corrects the rounding of numbers less than 10^(-width). Fixes typo in an error message. Updates copyright years Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&r1=1.26&r2=1.27 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.168&r2=1.169 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5145&r2=1.5146 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20124.f90.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed, thanks for your report.
Note I think this fixed a couple of SPEC 95 tests as they no longer mis compare.