diff lib/log10.c @ 16745:78fe2a20b15c

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