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]

[Patch, libgFortran] Increase the default precision for real(16) by one


Using the current settings  write(*,*) x  sometimes does not print all
possible digits of real(16) variables on S/380.

The result is that gfortran.dg/default_format_2.f90 FAILs. That test
case contains effectively:

      x = 1.0_16
      do i = 0, 200
        write (s,*) x
        read (s,*) y
        if (y /= x) res = res + 1
        x = nearest(x,-huge(x))
      end do

On S/380 this fails 7 times with the current setting; for these abs(x-y)
= 9.6296497219361792652798897129246366E-0035.

The solution is to simply print one more digit by default; one
additionally has to enlarge then the size of one character string in the
test suite as it is otherwise to short. I don't know whether it solves
some of the other failures on REAL(16) systems such as Debian's SPARC;
presumably it won't help on PowerPCs where the glibc seems to have a bug
(if I read PR24685 correctly).

The following patch has been build on x86-64 by me and bootstrapped and
regtested on S/390 by Andreas Krebbel.
OK for the trunk?

Tobias


2008-01-17  Tobias Burnus  <burnus@net-b.de>

	* io/write.c (write_real): Increase default precision for REAL(16) by one.

2008-01-17  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/large_real_kind_form_io_1.f90: Enlarge string for internal I/O.


Index: libgfortran/io/write.c
===================================================================
--- libgfortran/io/write.c      (Revision 131592)
+++ libgfortran/io/write.c      (Arbeitskopie)
@@ -713,8 +713,8 @@ write_real (st_parameter_dt *dtp, const
       f.u.real.e = 4;
       break;
     case 16:
-      f.u.real.w = 43;
-      f.u.real.d = 34;
+      f.u.real.w = 44;
+      f.u.real.d = 35;
       f.u.real.e = 4;
       break;
     default:

Index: gfortran.dg/large_real_kind_form_io_1.f90
===================================================================
--- gfortran.dg/large_real_kind_form_io_1.f90   (Revision 131624)
+++ gfortran.dg/large_real_kind_form_io_1.f90   (Arbeitskopie)
@@ -6,7 +6,7 @@
   integer, parameter :: k = selected_real_kind (precision (0.0_8) + 1)
   real(kind=k) :: a,b(2), c, eps
   complex(kind=k) :: d, e, f(2), g
-  character(len=180) :: tmp
+  character(len=200) :: tmp
   ! Test real(k) scalar and array formatted IO
   eps = 10 * spacing (2.0_k) ! 10 ulp precision is enough.
   b(:) = 2.0_k



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