This is the mail archive of the libc-alpha@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]

[PATCH] Fix formatting of denormal IBM long double numbers


	[BZ #13941]
        * sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
	(__mpn_extract_long_double): Use DBL_MIN_EXP instead of
	LDBL_MIN_EXP.
---
 sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
index 3162bbd..ed0c872 100644
--- a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
+++ b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006
-	Free Software Foundation, Inc.
+/* Copyright (C) 1995-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -104,7 +103,10 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
       else
 	{
 	  /* It is a denormal number, meaning it has no implicit leading
-  	     one bit, and its exponent is in fact the format minimum.  */
+	     one bit, and its exponent is in fact the format minimum.  We
+	     use DBL_MIN_EXP instead of LDBL_MIN_EXP below because the
+	     latter describes the properies of the both parts together,
+	     but the exponent is computed from the high part only.  */
 	  int cnt;
 
 #if N == 2
@@ -115,7 +117,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 	      res_ptr[N - 1] = res_ptr[N - 1] << cnt
 			       | (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
 	      res_ptr[0] <<= cnt;
-	      *expt = LDBL_MIN_EXP - 1 - cnt;
+	      *expt = DBL_MIN_EXP - 1 - cnt;
 	    }
 	  else
 	    {
@@ -130,7 +132,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 		  res_ptr[N - 1] = res_ptr[0] >> (NUM_LEADING_ZEROS - cnt);
 		  res_ptr[0] <<= BITS_PER_MP_LIMB - (NUM_LEADING_ZEROS - cnt);
 		}
-	      *expt = LDBL_MIN_EXP - 1
+	      *expt = DBL_MIN_EXP - 1
 		- (BITS_PER_MP_LIMB - NUM_LEADING_ZEROS) - cnt;
 	    }
 #else
@@ -161,7 +163,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 
 	  for (; k >= 0; k--)
 	    res_ptr[k] = 0;
-	  *expt = LDBL_MIN_EXP - 1 - l * BITS_PER_MP_LIMB - cnt;
+	  *expt = DBL_MIN_EXP - 1 - l * BITS_PER_MP_LIMB - cnt;
 #endif
 	}
     }
-- 
1.7.10


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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