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: [BZ #2549]: ulp computation doesn't support denormalized returns


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


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