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

[commits] r12583 - in /libdfp/trunk: ./ sysdeps/dpd/ tests/



Author: ryanarn
Date: Mon Jan 17 18:36:22 2011
New Revision: 12583

Log:
Checked in the following patch which fixed a bug in
sysdeps/dpd/dpd-private.c's dpd_to_char[0x3f4] element where what should be
"774" was actually "974".  This caused some values that fell on a particular
boundary to be displayed with ....974.... instead of ....774....  Added a new
testcase to verify correct behavior.

2011-01-17  Ryan S. Arnold  <rsa@xxxxxxxxxx>

	* Makefile.in (libdfp_tests): Added test-log10d.
	* tests/test-decode.c: Added decode of log10d128(0.0000000011DL) to
	verify that it prints correctly in declets.
	* tests/test-logd.c (main): Added pbuf[CHAR_MAX] so that tests work
	properly.
	* tests/test-log10d.c: New test-case which verifies that printf now
	works properly for the result of log10d128(0.0000000011DL).
	* sysdeps/dpd/dpd-private.c: Fixed dpd_to_char[0x3f4] from "974" to
	"774" since the previous was a typo which was making values print
	incorrectly.


Added:
    libdfp/trunk/tests/test-log10d.c
Modified:
    libdfp/trunk/ChangeLog
    libdfp/trunk/Makefile.in
    libdfp/trunk/sysdeps/dpd/dpd-private.c
    libdfp/trunk/tests/test-decode.c
    libdfp/trunk/tests/test-logd.c

Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Mon Jan 17 18:36:22 2011
@@ -1,3 +1,16 @@
+2011-01-17  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* Makefile.in (libdfp_tests): Added test-log10d.
+	* tests/test-decode.c: Added decode of log10d128(0.0000000011DL) to
+	verify that it prints correctly in declets.
+	* tests/test-logd.c (main): Added pbuf[CHAR_MAX] so that tests work
+	properly.
+	* tests/test-log10d.c: New test-case which verifies that printf now
+	works properly for the result of log10d128(0.0000000011DL).
+	* sysdeps/dpd/dpd-private.c: Fixed dpd_to_char[0x3f4] from "974" to
+	"774" since the previous was a typo which was making values print
+	incorrectly.
+
 2011-01-17  Ryan S. Arnold  <rsa@xxxxxxxxxx>
 
 	* configure: Regenerated.

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Mon Jan 17 18:36:22 2011
@@ -304,7 +304,7 @@
 GLIBC_LIBS := $(glibc_builddir)/libc.so $(glibc_builddir)/math/libm.so $(glibc_builddir)/nptl/libpthread.so
 endif
 
-libdfp_tests = test-printf test-param test-amort test-decode test-quantize test-isnan test-isinf test-isfinite test-fpclassify test-logd test-strtod test-numdigits test-get_digits test-round
+libdfp_tests = test-printf test-param test-amort test-decode test-quantize test-isnan test-isinf test-isfinite test-fpclassify test-logd test-log10d test-strtod test-numdigits test-get_digits test-round
 
 # Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just
 # built.

Modified: libdfp/trunk/sysdeps/dpd/dpd-private.c
==============================================================================
--- libdfp/trunk/sysdeps/dpd/dpd-private.c (original)
+++ libdfp/trunk/sysdeps/dpd/dpd-private.c Mon Jan 17 18:36:22 2011
@@ -200,9 +200,11 @@
 	"758", "759", "794", "795", "956", "957", "798", "799", /* 3d8-3df */
 	"760", "761", "762", "763", "764", "765", "766", "767", /* 3e0-3e7 */
 	"768", "769", "786", "787", "966", "967", "988", "989", /* 3e8-3ef */
-	"770", "771", "772", "773", "974", "775", "776", "777", /* 3f0-3f7 */
+	"770", "771", "772", "773", "774", "775", "776", "777", /* 3f0-3f7 */
 	"778", "779", "796", "797", "976", "977", "998", "999"  /* 3f8-3ff */
 	};
+
+//	"770", "771", "772", "773", "974", "775", "776", "777", /* 3f0-3f7 */
 
 /* Table to convert 3 Densely Packed Decimal digits (10-bits) into
    3 Binary coded Decimal digits (12-bits).  */
@@ -708,7 +710,8 @@
   str[16] = '\0';
   if (sign_p) *sign_p = d.ieee.negative;
 }
-else if (bits == 128)
+//else if (bits == 128)
+else
 {
   union ieee754r_Decimal128 d;
   d.td = *(_Decimal128*)args[0];
@@ -732,8 +735,6 @@
   str[34] = '\0';
   if (sign_p) *sign_p = d.ieee.negative;
 }
-else
-  return;
 
   str[0] = '0' + c_f.lmd;
   if (exp_p) *exp_p = exp;

Modified: libdfp/trunk/tests/test-decode.c
==============================================================================
--- libdfp/trunk/tests/test-decode.c (original)
+++ libdfp/trunk/tests/test-decode.c Mon Jan 17 18:36:22 2011
@@ -84,6 +84,8 @@
 #else
       {__LINE__,1.00DL, "BID not supported."},
 #endif
+      /* log10d128(0.0000000011DL)  */
+      {__LINE__, -8.958607314841774959249800028756976DL, "-8,958,607,314,841,774,959,249,800,028,756,976E-33"},
       {  0,0,0 }
     };
 

Added: libdfp/trunk/tests/test-log10d.c
==============================================================================
--- libdfp/trunk/tests/test-log10d.c (added)
+++ libdfp/trunk/tests/test-log10d.c Mon Jan 17 18:36:22 2011
@@ -1,0 +1,82 @@
+/* Test log10d[32|64|128].
+
+   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__
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro.  */
+
+#include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro.  */
+
+typedef struct{
+  int line;
+  _Decimal128 x;  /* Value to test  */
+  _Decimal128 e;  /* Result should be this.  */
+  const char *format; /* printf %DfDD */
+  char vorq;  /* value compare or printf compare (quantize equivalent)  */
+} d128_type;
+
+d128_type printf_d128s[] =
+{
+  /* This value revealed a typo in the dpd_to_char array in 
+   * sysdeps/dpd/dpd-private.c which is used as a lookup table.  What is now
+   * '774' was erroneously '974' and was resulting in incorrect display of the
+   * expected value.
+   *
+   * echo 'scale = 33; l(0.0000000011)/l(10)' | bc -l
+   * == -8.958607314841774959249800028756976  */
+  {__LINE__, 1.1E-9DL, -8.958607314841774959249800028756976DL, "%.34DDfDL",'v'},
+  {0,0,0,0,0 }
+};
+
+int main (void)
+{
+  d128_type *d128ptr;
+
+  for (d128ptr = printf_d128s; d128ptr->line; d128ptr += sizeof(_Decimal128 *))
+    {
+      _Decimal128 retval = log10d128(d128ptr->x);
+      fprintf(stdout,"%.34DDfDL = log10d128(%.34DDfDL) in: %s:%d\n", retval, d128ptr->x,__FILE__,__LINE__-1);
+      if(d128ptr->vorq == 'v')
+        _VC_P(__FILE__,d128ptr->line, d128ptr->e,retval,d128ptr->format);
+      if(d128ptr->e != retval)
+        {
+	  static char rbuf[CHAR_MAX];
+	  static char pbuf[CHAR_MAX];
+	  fprintf(stderr,"decoded128(retval) [%s] != decoded128(expected) [%s]\n", decoded128(retval, &rbuf[0]), decoded128(d128ptr->e, &pbuf[0]));
+	}
+    }
+
+  _REPORT();
+
+  /* fail comes from scaffold.c  */
+  return fail;
+}
+
+

Modified: libdfp/trunk/tests/test-logd.c
==============================================================================
--- libdfp/trunk/tests/test-logd.c (original)
+++ libdfp/trunk/tests/test-logd.c Mon Jan 17 18:36:22 2011
@@ -1,4 +1,4 @@
-/* Test islogd[32|64|128].
+/* Test logd[32|64|128].
 
    Copyright (C) 2010 Free Software Foundation, Inc.
 
@@ -80,8 +80,6 @@
   {0,0,0 }
 };
 
-
-
 int main (void)
 {
   d64_type *d64ptr;
@@ -96,7 +94,8 @@
       if(d64ptr->e != retval)
         {
 	  static char rbuf[CHAR_MAX];
-	  fprintf(stderr,"decoded64(retval) [%s] != decoded64(expected) [%s]\n", decoded64(retval, &rbuf[0]), decoded64(d64ptr->e, &rbuf[0]));
+	  static char pbuf[CHAR_MAX];
+	  fprintf(stderr,"decoded64(retval) [%s] != decoded64(expected) [%s]\n", decoded64(retval, &rbuf[0]), decoded64(d64ptr->e, &pbuf[0]));
 	}
     }