Bug 20124 - gfortran prints -.01 incorrectly
Summary: gfortran prints -.01 incorrectly
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-02-21 19:15 UTC by Dale Ranta
Modified: 2005-03-15 21:49 UTC (History)
2 users (show)

See Also:
Host: powerpc-apple-darwin7.8.0
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-21 19:23:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Ranta 2005-02-21 19:15:55 UTC
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
Comment 1 Andrew Pinski 2005-02-21 19:23:22 UTC
Confirmed.
Comment 2 Francois-Xavier Coudert 2005-02-24 16:24:53 UTC
$ 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).
Comment 3 Francois-Xavier Coudert 2005-02-24 17:38:06 UTC
Patch proposed in http://gcc.gnu.org/ml/fortran/2005-02/msg00315.html
Comment 4 GCC Commits 2005-03-11 08:03:02 UTC
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

Comment 5 GCC Commits 2005-03-11 08:03:10 UTC
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

Comment 6 Andrew Pinski 2005-03-11 14:16:52 UTC
Fixed, thanks for your report.
Comment 7 Andrew Pinski 2005-03-15 21:49:03 UTC
Note I think this fixed a couple of SPEC 95 tests as they no longer mis compare.