[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r11223 - in /libdfp/trunk: ChangeLog strtod32.c tests/test-amort.c tests/test-printf.c tests/test-strtod.c



Author: ryanarn
Date: Thu Aug 12 21:28:09 2010
New Revision: 11223

Log:
2010-08-12  Luis Machado  <luisgpm@xxxxxxxxxx>

	* tests/test-amort.c: Added license and copyright.
	* tests/test-printf.c: Updated copyright year.
	* tests/test-strtod.c: Added license and copyright.  Corrected
	incorrect expected values.
	* strtod32.c: Fixed several conversion bugs.


Modified:
    libdfp/trunk/ChangeLog
    libdfp/trunk/strtod32.c
    libdfp/trunk/tests/test-amort.c
    libdfp/trunk/tests/test-printf.c
    libdfp/trunk/tests/test-strtod.c

Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Thu Aug 12 21:28:09 2010
@@ -1,3 +1,11 @@
+2010-08-12  Luis Machado  <luisgpm@xxxxxxxxxx>
+
+	* tests/test-amort.c: Added license and copyright.
+	* tests/test-printf.c: Updated copyright year.
+	* tests/test-strtod.c: Added license and copyright.  Corrected
+	incorrect expected values.
+	* strtod32.c: Fixed several conversion bugs.
+
 2010-08-12  Ryan S. Arnold  <rsa@xxxxxxxxxx>
 
 	* Makefile.in: Removed test-left_justify from execution since it is a

Modified: libdfp/trunk/strtod32.c
==============================================================================
--- libdfp/trunk/strtod32.c (original)
+++ libdfp/trunk/strtod32.c Thu Aug 12 21:28:09 2010
@@ -659,7 +659,7 @@
   /* We have the number digits in the integer part.  Whether these are all or
      any is really a fractional digit will be decided later.  */
   int_no = dig_no;
-  lead_zero = int_no == 0 ? 1 : 0;  /* FIXME: Why was this -1 */
+  lead_zero = int_no == 0 ? -1 : 0;  /* FIXME: Why was this -1 */
 
   /* Read the fractional digits.  A special case are the 'american style'
      numbers like `16.' i.e. with decimal but without trailing digits.  */
@@ -844,6 +844,7 @@
 	  ++startp;
 	}
 #endif
+      lead_zero = (lead_zero < 0? 0 : lead_zero);
       startp += lead_zero + decimal_len;
       exponent -= base == 16 ? 4 * lead_zero : lead_zero;
       dig_no -= lead_zero;
@@ -930,13 +931,6 @@
 	    the string.  But these all can be ignored because we know the
 	    format of the number is correct and we have an exact number
 	    of characters to read.  */
-#ifdef USE_WIDE_CHAR
-      if (*startp < L_('0') || *startp > L_('9'))
-	++startp;
-#else
-      if (*startp < '0' || *startp > '9')
-	startp += decimal_len;
-#endif
 
       /*do
 	{
@@ -951,19 +945,31 @@
       frac /= 10;
 
       d32 += frac;*/
-      
+      int_no = 0;
       do
         {
-	  if(base == 10)
-	    d32 = d32*10 + *startp - L_('0');
-	  else
-	    d32 = d32*10 + (*startp >= L_('0') && 
+#ifdef USE_WIDE_CHAR
+      if (*startp < L_('0') || *startp > L_('9'))
+	++startp;
+#else
+      if (*startp < '0' || *startp > '9')
+	startp += decimal_len;
+#endif
+
+	if (int_no <= MANT_DIG)
+	  {
+	    if(base == 10)
+	      d32 = d32*10 + *startp - L_('0');
+	    else
+	      d32 = d32*10 + (*startp >= L_('0') &&
 		*startp <= L_('9') ? -L_('0') : 10-L_('a'))
 		+ *startp;
-	  ++startp;
-	  --exponent;
-        }
-      while (--digcnt > 0);
+	    ++startp;
+	    --exponent;
+	    int_no++;
+	  }
+	}
+    while (--digcnt > 0);
     }
 
 #if NUMDIGITS_SUPPORT==0

Modified: libdfp/trunk/tests/test-amort.c
==============================================================================
--- libdfp/trunk/tests/test-amort.c (original)
+++ libdfp/trunk/tests/test-amort.c Thu Aug 12 21:28:09 2010
@@ -1,3 +1,29 @@
+/* Amortization Benchmarck
+
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Peter Eberlein <eberlein@xxxxxxxxxx>
+              Steven Munroe <munroesj@xxxxxxxxxx>
+              Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library is distributed in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+   the GNU Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see libdfp/COPYING.txt for more information.  */
+
 /*
 set -ex
 
@@ -43,22 +69,12 @@
 exit
 */
 
-
-
-/* File test_amort.c created by sjmunroe on Mon Oct 30 2006. */
-/* -std=gnu99 */
-/* #define __STDC_WANT_DEC_FP__ 1 */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <float.h>
 #include <math.h>
 #include <sys/time.h>
-
-//extern _Decimal64 powd64 (_Decimal64, _Decimal64);
-//extern _Decimal64 quantized64 (_Decimal64, _Decimal64);
-//extern _Decimal64 strtod64 (char *, char *);
 
 typedef struct
 {
@@ -114,7 +130,6 @@
 {
   _Decimal64 months = years * 12.0DD;
   _Decimal64 monthly_rate = yearly_rate / 12.0DD;
-  //_Decimal64 temp0, temp1, temp2, temp3;
   _Decimal64 temp0;
   _Decimal64 principal, principal_payed, interest_payed;
   _Decimal64 accum_principal, accum_interest;
@@ -207,7 +222,6 @@
 static void
 armort_verifier (inputtype *inputs, int numinputs)
 {
-//	_Decimal64 payment;
 	int i;
 	
 	for (i = 0; i < numinputs; i++)

Modified: libdfp/trunk/tests/test-printf.c
==============================================================================
--- libdfp/trunk/tests/test-printf.c (original)
+++ libdfp/trunk/tests/test-printf.c Thu Aug 12 21:28:09 2010
@@ -1,6 +1,6 @@
 /* Test printf_dfp facility.
 
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
 

Modified: libdfp/trunk/tests/test-strtod.c
==============================================================================
--- libdfp/trunk/tests/test-strtod.c (original)
+++ libdfp/trunk/tests/test-strtod.c Thu Aug 12 21:28:09 2010
@@ -1,3 +1,27 @@
+/* Test strtod[32|64|128] facility.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library is distributed in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+   the GNU Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see libdfp/COPYING.txt for more information.  */
+
 #ifndef __STDC_WANT_DEC_FP__
 # define __STDC_WANT_DEC_FP__ 1
 #endif
@@ -40,7 +64,7 @@
   {__LINE__, "19e9", 19000000000.0DF, 19000000000.0DD, 19000000000.0DL },
   {__LINE__, "3.14", 3.140000DF, 3.140000DD, 3.140000DL },
   {__LINE__, "3.14e-2", 0.031400DF, 0.031400DD, 0.031400DL },
-  {__LINE__, "1234.5678910111213e-5", 0.012346DF ,0.012346DD ,0.012346DL },
+  {__LINE__, "1234.5678910111213e-5", 0.01234568DF ,0.01234567891011121DD ,0.012345678910111213DL },
   {0,0,0,0,0 }
 };
 
@@ -62,7 +86,8 @@
   /* Compare against the decoded declet for each representation of DEC_NAN since
    * since you can't compare DEC_NAN to DEC_NAN.  */
   {__LINE__, "NaN", DECLET32_NAN, DECLET64_NAN, DECLET128_NAN},
-  {__LINE__, "1.23456789E-7", "+1,234,568E-14", "+0,000,000,123,456,789E-15", "+0,000,000,000,000,000,000,000,000,123,456,789E-15" },
+  {__LINE__, "1.23456789E-7", "+1,234,568E-13",        "+0,000,000,123,456,789E-15", "+0,000,000,000,000,000,000,000,000,123,456,789E-15" },
+  {__LINE__, "1234.5678910111213e-5", "+1,234,568E-8", "+1,234,567,891,011,121E-17", "+0,000,000,000,000,000,012,345,678,910,111,213E-18" },
   {0,0,0,0,0 }
 };