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

[Bug math/887] Math library function "logb" and "nextafter" inconsistent


http://sourceware.org/bugzilla/show_bug.cgi?id=887

--- Comment #20 from Ryan S. Arnold <rsa at us dot ibm.com> 2012-03-26 20:09:40 UTC ---
Here's a more thorough patch which includes -frounding-math when building
s_logb.c and only tests on 'double'.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 3851855..df83a45 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -5000,6 +5000,41 @@ logb_test (void)
   END (logb);
 }

+static void
+logb_test_downward (void)
+{
+  int save_round_mode;
+  errno = 0;
+
+  FUNC(logb) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (logb_downward);
+
+  save_round_mode = fegetround ();
+
+  if (!fesetround (FE_DOWNWARD))
+    {
+
+      /* IEEE 754-2008 says (section 5.3.3) that "logB(1) is +0.".  Libm
+       * should not return -0 from logb in any rounding mode.  PowerPC32 is
+       * known to fail with this test for power4 and earlier hardware due
+       * the instructions available for the logb computation at the POWER4
+       * and earlier ISA level.  POWER4 uses an fsub in the calculation which
+       * propogates a negative sign in a downward rounding mode.  */
+
+#if defined TEST_DOUBLE
+      /* BZ #887 .*/
+      TEST_f_f (logb, 1.000e+0, plus_zero);
+#endif /* TEST_DOUBLE  */
+    }
+
+  fesetround (save_round_mode);
+
+  END (logb_downward);
+}

 static void
 lround_test (void)
@@ -7834,6 +7869,7 @@ main (int argc, char **argv)
   log1p_test ();
   log2_test ();
   logb_test ();
+  logb_test_downward ();
   modf_test ();
   ilogb_test ();
   scalb_test ();
diff --git a/sysdeps/powerpc/powerpc32/Makefile
b/sysdeps/powerpc/powerpc32/Makefile
index aa2d0b9..638e177 100644
--- a/sysdeps/powerpc/powerpc32/Makefile
+++ b/sysdeps/powerpc/powerpc32/Makefile
@@ -42,3 +42,9 @@ ifeq ($(subdir),elf)
 # extra shared linker files to link only into dl-allobjs.so
 sysdep-rtld-routines += dl-start
 endif
+
+# BZ #887 logb for powerpc32 power4 ISA and earlier exhibits a negative sign
+# on zero from a downward round.
+ifeq ($(subdir),math)
+CFLAGS-s_logb.c += -frounding-math
+endif

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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