This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [gfortran] PR libfortran/21376


Attached patch fixes PR libfortran/21376 (library called log10 with argument equal to zero). Simple reworking of logic to avoid that.

Regtesting in progress on i686-linux. OK for 4.0 and mainline?

"Attached patch" is now really attached. Sorry.


FX
2005-05-22  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR libfortran/21376
	* io/write.c (output_float): Rework logic to avoid call to log10
	with argument equal to zero.

Index: libgfortran/io/write.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.37
diff -p -u -r1.37 write.c
--- libgfortran/io/write.c	17 May 2005 16:54:51 -0000	1.37
+++ libgfortran/io/write.c	22 May 2005 18:29:31 -0000
@@ -296,6 +296,7 @@ output_float (fnode *f, double value)
   int nblanks;
   int i;
   sign_t sign;
+  double abslog;
 
   ft = f->format;
   w = f->u.real.w;
@@ -320,9 +321,11 @@ output_float (fnode *f, double value)
     edigits = 2;
   else
     {
-      edigits = 1 + (int) log10 (fabs(log10 (value)));
-      if (edigits < 2)
+      abslog = fabs(log10 (value));
+      if (abslog < 100)
 	edigits = 2;
+      else
+        edigits = 1 + (int) log10 (abslog);
     }
 
   if (ft == FMT_F || ft == FMT_EN

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