This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] BZ#15536: Fix ulp(0x0.0p0) for 128-bit IBM long double.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Andreas Schwab <schwab at suse dot de>, Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- Date: Fri, 31 May 2013 13:54:52 -0400
- Subject: Re: [PATCH] BZ#15536: Fix ulp(0x0.0p0) for 128-bit IBM long double.
- References: <51A84400 dot 80005 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1305311709150 dot 9860 at digraph dot polyomino dot org dot uk>
On 05/31/2013 01:12 PM, Joseph S. Myers wrote:
> On Fri, 31 May 2013, Carlos O'Donell wrote:
>
>> +#if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106
>> + /* In 128-bit IBM long double the precision of the type degenerates
>> + to double when we use subnormals. */
>> + ulp = FUNC(ldexp) (1.0, 1 - (MAX_EXP + (__DBL_MANT_DIG__ - 1)));
>> +#else
>> ulp = FUNC(ldexp) (1.0, 1 - (MAX_EXP + MANT_DIG));
>> +#endif
>
> Rather than having such a conditional at all, I think you should define
> things in terms of MIN_EXP and MANT_DIG, where a single piece of logic
> should give 0x1p-1074 for both double and IBM long double.
Is that what you were thinking?
The following passes no regressions (other than the inaccuracies)
on x86_64 and Power64 and should do the right thing.
v2
- Use DBL_MANT_DIG.
v3
- Use MIN_EXP - MANT_DIG.
2013-05-31 Carlos O'Donell <carlos@redhat.com>
[BZ #15536]
* math/libm-test.inc (MAX_EXP): Remove
(MIN_EXP): Define.
(ulp): Use MIN_EXP - MANT_DIG.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 7a6bf09..fd0df6a 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -269,8 +269,8 @@ static FLOAT max_error, real_max_error, imag_max_error;
#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \
(LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
-#define MAX_EXP CHOOSE ((LDBL_MAX_EXP-1), (DBL_MAX_EXP-1), (FLT_MAX_EXP-1), \
- (LDBL_MAX_EXP-1), (DBL_MAX_EXP-1), (FLT_MAX_EXP-1))
+#define MIN_EXP CHOOSE ((LDBL_MIN_EXP), (DBL_MIN_EXP), (FLT_MIN_EXP), \
+ (LDBL_MIN_EXP), (DBL_MIN_EXP), (FLT_MIN_EXP))
/* Compare KEY (a string, with the name of a test or a function) with
ULP (a pointer to a struct ulp_data structure), returning a value
@@ -680,7 +680,7 @@ ulp (FLOAT value)
/* Fall through... */
case FP_SUBNORMAL:
/* The next closest subnormal value is a constant distance away. */
- ulp = FUNC(ldexp) (1.0, 1 - (MAX_EXP + MANT_DIG));
+ ulp = FUNC(ldexp) (1.0, MIN_EXP - MANT_DIG);
break;
case FP_NORMAL:
---
Cheers,
Carlos.