diff lib/log10f.c @ 16747:676471a1cb33

log10f-ieee: Work around test failure on NetBSD 5.1. * m4/log10f-ieee.m4: New file. * m4/log10f.m4 (gl_FUNC_LOG10F): If gl_FUNC_LOG10F_IEEE is present, test whether log10f works with a negative argument. Replace it if not. * lib/log10f.c (log10f): For negative arguments, return NaN. * modules/log10f-ieee (Files): Add m4/log10f-ieee.m4. (configure.ac): Invoke gl_FUNC_LOG10F_IEEE. * doc/posix-functions/log10f.texi: Mention the log10f-ieee module.
author Bruno Haible <bruno@clisp.org>
date Sun, 01 Apr 2012 17:56:33 +0200
parents 6828b991e3b9
children e542fd46ad6f
line wrap: on
line diff
--- a/lib/log10f.c
+++ b/lib/log10f.c
@@ -24,10 +24,17 @@
 #undef log10f
 {
 #if HAVE_LOG10F
-  /* Work around the OSF/1 5.1 bug.  */
-  if (x == 0.0f)
-    /* Return -Infinity.  */
-    return -1.0f / 0.0f;
+  if (x <= 0.0f)
+    {
+      /* Work around the OSF/1 5.1 bug.  */
+      if (x == 0.0f)
+        /* Return -Infinity.  */
+        return -1.0f / 0.0f;
+      /* Work around the NetBSD 5.1 bug.  */
+      else /* x < 0.0 */
+        /* Return NaN.  */
+        return 0.0f / 0.0f;
+    }
   return log10f (x);
 #else
   return (float) log10 ((double) x);