Patchwork [libquadmath,committed] Fix exponent reading

login
register
mail settings
Submitter Tobias Burnus
Date Dec. 3, 2012, 4:18 p.m.
Message ID <50BCD0CF.6070907@net-b.de>
Download mbox | patch
Permalink /patch/203395/
State New
Headers show

Comments

Tobias Burnus - Dec. 3, 2012, 4:18 p.m.
Somehow that got lot when updating the file. I think, we really need a 
proper test suite - the current quad_{1,2,3}.f90 are a first step, but 
rather incomplete.

Committed as Rev. 194100 after build+regtesting.

Tobias

Patch

Index: libquadmath/ChangeLog
===================================================================
--- libquadmath/ChangeLog	(Revision 194099)
+++ libquadmath/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-12-03  Tobias Burnus  <burnus@net-b.de>
+
+	* strtod/strtod_l.c (___STRTOF_INTERNAL): Fix exponent
+	reading.
+
 2012-11-25  Tobias Burnus  <burnus@net-b.de>
 
 	PR libquadmath/55462
Index: libquadmath/strtod/strtod_l.c
===================================================================
--- libquadmath/strtod/strtod_l.c	(Revision 194099)
+++ libquadmath/strtod/strtod_l.c	(Arbeitskopie)
@@ -1005,6 +1005,9 @@  ____STRTOF_INTERNAL (nptr, endptr, group)
 		  /* NOTREACHED */
 		}
 
+	      exponent *= 10;
+	      exponent += c - L_('0');
+
 	      c = *++cp;
 	    }
 	  while (c >= L_('0') && c <= L_('9'));
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 194099)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,7 @@ 
+2012-12-03  Tobias Burnus  <burnus@net-b.de>
+
+	* gfortran.dg/quad_3.f90: New.
+
 2012-12-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR c++/54170
Index: gcc/testsuite/gfortran.dg/quad_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/quad_3.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/quad_3.f90	(Arbeitskopie)
@@ -0,0 +1,27 @@ 
+! { dg-do run }
+!
+! I/O test for REAL(16)
+!
+! Contributed by Dominique d'Humieres
+!
+program test_qp
+   use iso_fortran_env, only: real_kinds
+   implicit none
+   integer, parameter :: QP = real_kinds(ubound(real_kinds,dim=1))
+   real(kind=qp) :: a,b(2), c
+   integer :: exponent
+   character(len=180) :: tmp
+
+   ! Run this only with libquadmath; assume that all those systems
+   ! have also kind=10.
+   if (size (real_kinds) >= 4 .and. real_kinds(3) == 10 .and. qp == 16) then
+     exponent = 4000
+     b(:) = huge (1.0_qp)/10.0_qp**exponent
+!     print *, 'real(16) big value:      ', b(1)
+     write (tmp, *) b
+     read (tmp, *) a, c
+!     print *, 'same value read again:   ', a, c
+!     print *, 'difference: looks OK now ', a-b(1)
+     if (a-b(1) /= 0.0_qp .or. c-b(1) /= 0.0_qp) call abort()
+   end if
+end program test_qp