This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: [BZ #2549]: ulp computation doesn't support denormalized returns
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Fri, 14 Apr 2006 10:36:19 -0700
- Subject: PATCH: [BZ #2549]: ulp computation doesn't support denormalized returns
- References: <20060411225857.GA6882@lucon.org> <hoslojnpfi.fsf@reger.suse.de>
On Wed, Apr 12, 2006 at 10:55:29AM +0200, Andreas Jaeger wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
>
> > I'd like to contribute some new libm tests. I am enclosing the new
> > double test result here. I have 3 questions:
> >
> > 1. The current way ulp computation doesn't support denormalized
> > numbers. Should we skip those tests?
>
> We need to handle this somehow - this is an extension of the
> framework.
>
This patch handles FP_SUBNORMAL by multiplying 2 raised to the power
MANT_DIG.
H.J.
---
2006-04-14 H.J. Lu <hongjiu.lu@intel.com>
[BZ #2549]
* math/libm-test.inc (check_float_internal): Support
denormalized return.
--- math/libm-test.inc.ulp 2006-04-14 09:15:03.000000000 -0700
+++ math/libm-test.inc 2006-04-14 10:28:11.000000000 -0700
@@ -487,11 +487,23 @@ check_float_internal (const char *test_n
else
{
diff = FUNC(fabs) (computed - expected);
- /* ilogb (0) isn't allowed. */
- if (expected == 0.0)
- ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
- else
- ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
+ switch (fpclassify (expected))
+ {
+ case FP_ZERO:
+ /* ilogb (0) isn't allowed. */
+ ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
+ break;
+ case FP_NORMAL:
+ ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
+ break;
+ case FP_SUBNORMAL:
+ ulp = FUNC(ldexp) (diff, MANT_DIG) / FUNC(ldexp) (1.0, FUNC(ilogb) (expected));
+ break;
+ default:
+ /* It should never happen. */
+ abort ();
+ break;
+ }
set_max_error (ulp, curr_max_error);
print_diff = 1;
if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0