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]

Re: sparc, ia64: Compute cos(M_PI_2l) for your 128-bit long double please.


On 04/11/2013 09:09 AM, Rich Felker wrote:
> On Thu, Apr 11, 2013 at 03:06:47PM +0200, Andreas Schwab wrote:
>> Rich Felker <dalias@aerifal.cx> writes:
>>
>>> I would just use something like "%.100000g\n".
>>
>> If you use %g you need at most DECIMAL_DIG digits.
> 
> No, that's wrong. DECIMAL_DIG is sufficient if you want to round-trip
> the value back. But here we want to print the exact value in order to
> use an external tool to apply cos() to that value.
> 
> Rich

I got a hold of an s390x and ppc box to do additional testing with.

The following is a conversion of the long double constants into
hex literal equivalents with the maximum precision allowed by the
type. There should be no loss of precision in the answers now.

This does not fix PR/15359, since that turns out to be an inaccurate
cos for IBM long double (http://sourceware.org/bugzilla/show_bug.cgi?id=15359).

Any objections to using hex literals here?

2013-04-12  Carlos O'Donell  <carlos@redhat.com>

	* math/libm-test.inc (cos_test): Use highest precision hex constant.
	(sincos_test): Likewise.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 0049fcd..f0eb81a 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -5337,23 +5337,23 @@ cos_test (void)
      to each type.  */
 #ifdef TEST_FLOAT
   /* 32-bit float.  */
-  TEST_f_f (cos, M_PI_2l, -4.371139000186241438857289400265215e-8L);
+  TEST_f_f (cos, M_PI_2l, -0x1.777a5cp-25L);
 #endif
 #if defined TEST_DOUBLE || (defined TEST_LDOUBLE && LDBL_MANT_DIG == 53)
   /* 64-bit double or 64-bit long double.  */
-  TEST_f_f (cos, M_PI_2l, 6.123233995736765886130329661375001e-17L);
+  TEST_f_f (cos, M_PI_2l, 0x1.1a62633145c07p-54L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 64
   /* 96-bit long double.  */
-  TEST_f_f (cos, M_PI_2l, -2.50827880633416601177866354016537e-20L);
+  TEST_f_f (cos, M_PI_2l, -0xe.ce675d1fc8f8cbbp-69L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106
   /* 128-bit IBM long double.  */
-  TEST_f_f (cos, M_PI_2l, 1.082856673921913968223746169860580e-32L);
+  TEST_f_f (cos, M_PI_2l, 0x1.c1cd129024e088a67cc74020bcp-107L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 113
   /* 128-bit long double.  */
-  TEST_f_f (cos, M_PI_2l, 4.335905065061890512398522013021675e-35L);
+  TEST_f_f (cos, M_PI_2l, 0x1.cd129024e088a67cc74020bbea64p-115L);
 #endif
 
   TEST_f_f (cos, 0.75L, 0.731688868873820886311838753000084544L);
@@ -12164,23 +12164,23 @@ sincos_test (void)
      to each type.  */
 #ifdef TEST_FLOAT
   /* 32-bit float.  */
-  TEST_extra (sincos, M_PI_2l, 1, -4.371139000186241438857289400265215e-8L);
+  TEST_extra (sincos, M_PI_2l, 1, -0x1.777a5cp-25L);
 #endif
 #if defined TEST_DOUBLE || (defined TEST_LDOUBLE && LDBL_MANT_DIG == 53)
   /* 64-bit double or 64-bit long double.  */
-  TEST_extra (sincos, M_PI_2l, 1, 6.123233995736765886130329661375001e-17L);
+  TEST_extra (sincos, M_PI_2l, 1, 0x1.1a62633145c07p-54L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 64
   /* 96-bit long double.  */
-  TEST_extra (sincos, M_PI_2l, 1, -2.50827880633416601177866354016537e-20L);
+  TEST_extra (sincos, M_PI_2l, 1, -0xe.ce675d1fc8f8cbbp-69L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106
   /* 128-bit IBM long double.  */
-  TEST_extra (sincos, M_PI_2l, 1, 1.082856673921913968223746169860580e-32L);
+  TEST_extra (sincos, M_PI_2l, 1, 0x1.c1cd129024e088a67cc74020bcp-107L);
 #endif
 #if defined TEST_LDOUBLE && LDBL_MANT_DIG == 113
   /* 128-bit long double.  */
-  TEST_extra (sincos, M_PI_2l, 1, 4.335905065061890512398522013021675e-35L);
+  TEST_extra (sincos, M_PI_2l, 1, 0x1.cd129024e088a67cc74020bbea64p-115L);
 #endif
 
   TEST_extra (sincos, M_PI_6l, 0.5, 0.86602540378443864676372317075293616L);
---

Cheers,
Carlos.


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