This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc 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]

GNU C Library master sources branch master updated. glibc-2.22-311-ge27fcd0


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  e27fcd027cbdc2f13bf440177c0434eb9ec3dd28 (commit)
      from  7cda516f5f23772fd37ca3a5e018fca5bf388435 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=e27fcd027cbdc2f13bf440177c0434eb9ec3dd28

commit e27fcd027cbdc2f13bf440177c0434eb9ec3dd28
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Oct 1 15:24:54 2015 +0000

    Use type-specific precision when printing results in libm-test.inc.
    
    When libm-test.inc prints the results of failing tests, the output can
    be unhelpful for ldbl-128 and ldbl-128ibm because the precision used
    is insufficient to distinguish values of those types, resulting in
    reported values that look identical but differ by a large number of
    ulps.
    
    This patch changes it to use a precision appropriate for the type, for
    both decimal and hex output (so output for float is more compact,
    output for ldbl-128 and ldbl-128ibm is substantially wider).  The
    natural precision to use for decimal is given by the C11 <float.h>
    macros such as FLT_DECIMAL_DIG.  GCC's <float.h> only defines those in
    C11 mode, so this patch uses the predefines such as
    __FLT_DECIMAL_DIG__ (added in GCC 4.6) instead; if we move to building
    with -std=gnu11 (or -std=gnu1x if we can't get rid of 4.6 support).
    
    Tested for powerpc and mips64.
    
    	* math/libm-test.inc (TYPE_DECIMAL_DIG): New macro.
    	(TYPE_HEX_DIG): Likewise.
    	(print_float): Use TYPE_DECIMAL_DIG - 1 and TYPE_HEX_DIG - 1 as
    	precisions when printing floating-point numbers.
    	(check_float_internal): Likewise.

diff --git a/ChangeLog b/ChangeLog
index a88defa..6da0652 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-10-01  Joseph Myers  <joseph@codesourcery.com>
+
+	* math/libm-test.inc (TYPE_DECIMAL_DIG): New macro.
+	(TYPE_HEX_DIG): Likewise.
+	(print_float): Use TYPE_DECIMAL_DIG - 1 and TYPE_HEX_DIG - 1 as
+	precisions when printing floating-point numbers.
+	(check_float_internal): Likewise.
+
 2015-09-30  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #16620]
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 8615957..f627296 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -338,6 +338,18 @@ static FLOAT max_valid_error;
 			 (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
 #define MIN_EXP CHOOSE ((LDBL_MIN_EXP-1), (DBL_MIN_EXP-1), (FLT_MIN_EXP-1),	\
 			(LDBL_MIN_EXP-1), (DBL_MIN_EXP-1), (FLT_MIN_EXP-1))
+/* Sufficient numbers of digits to represent any floating-point value
+   unambiguously (for any choice of the number of bits in the first
+   hex digit, in the case of TYPE_HEX_DIG).  When used with printf
+   formats where the precision counts only digits after the point, 1
+   is subtracted from these values. */
+#define TYPE_DECIMAL_DIG CHOOSE (__DECIMAL_DIG__,	\
+				 __DBL_DECIMAL_DIG__,	\
+				 __FLT_DECIMAL_DIG__,	\
+				 __DECIMAL_DIG__,	\
+				 __DBL_DECIMAL_DIG__,	\
+				 __FLT_DECIMAL_DIG__)
+#define TYPE_HEX_DIG ((MANT_DIG + 7) / 4)
 
 /* Compare KEY (a string, with the name of a function) with ULP (a
    pointer to a struct ulp_data structure), returning a value less
@@ -419,7 +431,8 @@ print_float (FLOAT f)
   else if (isnan (f))
     printf ("qNaN\n");
   else
-    printf ("% .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n", f, f);
+    printf ("% .*" PRINTF_EXPR "  % .*" PRINTF_XEXPR "\n",
+	    TYPE_DECIMAL_DIG - 1, f, TYPE_HEX_DIG - 1, f);
 }
 
 /* Should the message print to screen?  This depends on the verbose flag,
@@ -837,8 +850,8 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
       print_float (expected);
       if (print_diff)
 	{
-	  printf (" difference: % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR
-		  "\n", diff, diff);
+	  printf (" difference: % .*" PRINTF_EXPR "  % .*" PRINTF_XEXPR
+		  "\n", TYPE_DECIMAL_DIG - 1, diff, TYPE_HEX_DIG - 1, diff);
 	  printf (" ulp       : % .4" PRINTF_NEXPR "\n", ulps);
 	  printf (" max.ulp   : % .4" PRINTF_NEXPR "\n", max_ulp);
 	}

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |    8 ++++++++
 math/libm-test.inc |   19 ++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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