Use a more portable replacement expression for -0.0L.
authorBruno Haible <bruno@clisp.org>
Wed, 8 Oct 2008 00:05:26 +0000 (02:05 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Oct 2008 00:05:26 +0000 (02:05 +0200)
31 files changed:
ChangeLog
m4/signbit.m4
modules/ceill-tests
modules/floorl-tests
modules/frexpl-tests
modules/isnan-tests
modules/isnanl-nolibm-tests
modules/isnanl-tests
modules/ldexpl-tests
modules/roundl-tests
modules/signbit-tests
modules/snprintf-posix-tests
modules/sprintf-posix-tests
modules/truncl-tests
modules/vasnprintf-posix-tests
modules/vasprintf-posix-tests
modules/vsnprintf-posix-tests
modules/vsprintf-posix-tests
tests/test-ceill.c
tests/test-floorl.c
tests/test-frexpl.c
tests/test-isnan.c
tests/test-isnanl.h
tests/test-ldexpl.c
tests/test-roundl.c
tests/test-signbit.c
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-truncl.c
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index 04d5f433910ece73287ba287a4962527d1fcc35c..931b308c9c82bc5795c0bd6e4927b20c785a5691 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,81 @@
+2008-10-07  Bruno Haible  <bruno@clisp.org>
+
+       Use a more portable replacement expression for -0.0L.
+       * m4/signbit.m4 (gl_SIGNBIT_TEST_PROGRAM): Use -LDBL_MIN * LDBL_MIN
+       instead of -0.0L. Fix m4 quotation.
+
+       * tests/test-signbit.c: Include <float.h>.
+       (minus_zero): New variable.
+       (test_signbitl): Use minus_zero instead of -zero.
+       * modules/signbit-tests (Depends-on): Add float.
+
+       * tests/test-ceill.c: Include <float.h>.
+       (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/ceill-tests (Depends-on): Add float.
+
+       * tests/test-floorl.c: Include <float.h>.
+       (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/floorl-tests (Depends-on): Add float.
+
+       * tests/test-roundl.c: Include <float.h>.
+       (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/roundl-tests (Depends-on): Add float.
+
+       * tests/test-truncl.c: Include <float.h>.
+       (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/truncl-tests (Depends-on): Add float.
+
+       * tests/test-frexpl.c (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/frexpl-tests (Depends-on): Add float.
+
+       * tests/test-isnan.c (zerol): Remove variable.
+       (minus_zerol): New variable.
+       (test_long_double): Use minus_zerol instead of -zerol.
+       * modules/isnan-tests (Depends-on): Add float.
+
+       * tests/test-isnanl.h (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/isnanl-nolibm-tests (Depends-on): Add float.
+       * modules/isnanl-tests (Depends-on): Add float.
+
+       * tests/test-ldexpl.c (zero): Remove variable.
+       (minus_zero): New variable.
+       (main): Use minus_zero instead of -zero.
+       * modules/ldexpl-tests (Depends-on): Add float.
+
+       * tests/test-snprintf-posix.h (zerol): Remove variable.
+       (minus_zerol): New variable.
+       (test_function): Use minus_zerol instead of -zerol.
+       * modules/snprintf-posix-tests (Depends-on): Add float.
+       * modules/vsnprintf-posix-tests (Depends-on): Add float.
+
+       * tests/test-sprintf-posix.h (zerol): Remove variable.
+       (minus_zerol): New variable.
+       (test_function): Use minus_zerol instead of -zerol.
+       * modules/sprintf-posix-tests (Depends-on): Add float.
+       * modules/vsprintf-posix-tests (Depends-on): Add float.
+
+       * tests/test-vasnprintf-posix.c (zerol): Remove variable.
+       (minus_zerol): New variable.
+       (test_function): Use minus_zerol instead of -zerol.
+       * modules/vasnprintf-posix-tests (Depends-on): Add float.
+
+       * tests/test-vasprintf-posix.c (zerol): Remove variable.
+       (minus_zerol): New variable.
+       (test_function): Use minus_zerol instead of -zerol.
+       * modules/vasprintf-posix-tests (Depends-on): Add float.
+
 2008-10-07  Simon Josefsson  <simon@josefsson.org>
 
        * MODULES.html.sh (Support for building documentation): Mention
index 17484532b37e76c18f3498ec85ba7fadc3c097aa..40ef49c67a234dc8b5baf7babd7cfa62ee7f856b 100644 (file)
@@ -1,4 +1,4 @@
-# signbit.m4 serial 3
+# signbit.m4 serial 4
 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -123,15 +123,21 @@ AC_DEFUN([gl_SIGNBIT],
   fi
 ])
 
-AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [
+AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -p0f instead.  */
+   So we use -p0f and -p0d instead.  */
 float p0f = 0.0f;
 float m0f = -p0f;
 double p0d = 0.0;
 double m0d = -p0d;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use another constant expression instead.  */
 long double p0l = 0.0L;
+#ifdef __hpux
+long double m0l = -LDBL_MIN * LDBL_MIN;
+#else
 long double m0l = -p0l;
+#endif
 int main ()
 {
   {
@@ -169,7 +175,7 @@ int main ()
   }
   return 0;
 }
-])
+]])
 
 AC_DEFUN([gl_FLOAT_SIGN_LOCATION],
 [
index ef0bc8f1f0169acecb1a6ed3cf8b0f5402f04267..381b3a5ed0060df1777906dd17b9d0212ef10984 100644 (file)
@@ -4,6 +4,7 @@ tests/test-ceill.c
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
index 4354d663b44cc06545bea112bde8388cf109d316..7aef91d24c9d4c009c23786806c113e89136b33d 100644 (file)
@@ -4,6 +4,7 @@ tests/test-floorl.c
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
index 572265d077cb2882ffea66476285275bfdfd3a59..e3b2d55c69def00ccd60cc2c40e817ae7ca71f53 100644 (file)
@@ -5,6 +5,7 @@ Depends-on:
 fpucw
 isnanl-nolibm
 signbit
+float
 
 configure.ac:
 
index f06a783946ac1af7c309ecdf92e4fbacfe519aa9..d5aff2a91f79a2d57c6a866f55eaeab53c278d9c 100644 (file)
@@ -3,6 +3,7 @@ tests/test-isnan.c
 tests/nan.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_FLOAT_EXPONENT_LOCATION
index e69130d473fb8b18a3903d4ff25e79bcbb523c88..a2e241c96f714fa9275816458fbcf365bf030eb1 100644 (file)
@@ -3,6 +3,7 @@ tests/test-isnanl-nolibm.c
 tests/test-isnanl.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
index 4194c4fc1836d7bad0a7705ad28cf358986a4546..7b4086e6e61d9e48754a9ade655c741c53bca5a7 100644 (file)
@@ -3,6 +3,7 @@ tests/test-isnanl.c
 tests/test-isnanl.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
index 7421227ea80e41503542be3137327bd9bb608b47..6c88bfdaceaa97d567860ca8796456ff1f1a81b8 100644 (file)
@@ -5,6 +5,7 @@ Depends-on:
 fpucw
 isnanl-nolibm
 signbit
+float
 
 configure.ac:
 
index 957c9341dd2aa6137a8aa0831624e0c672c8ae05..8e329a5c2149a62cddfac248634d37732c8d7906 100644 (file)
@@ -4,6 +4,7 @@ tests/test-roundl.c
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
index 86d66bf82bc822bbf2338c1977ff64429b3841d5..25851c90de2612846039477cc131e2ccd5f2911e 100644 (file)
@@ -5,6 +5,7 @@ m4/exponentd.m4
 m4/exponentl.m4
 
 Depends-on:
+float
 
 configure.ac:
 AC_REQUIRE([gl_FLOAT_EXPONENT_LOCATION])
index 5af4266aca514a64d3d8453cf97f0977d3ba1a53..f3c08c717407a0c8f2863c30a5318e631367c3b0 100644 (file)
@@ -6,6 +6,7 @@ tests/nan.h
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 AC_DEFINE([CHECK_SNPRINTF_POSIX], 1,
index cf67204381302ee12bbb23fe701eb09edacb11de..7ed1fb5da9a70777c508489cc512a095fd3401d8 100644 (file)
@@ -5,6 +5,7 @@ tests/nan.h
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
index aeb76af12f7ec1ffc6f8a2a0bbcc4849017e2285..236585475aa79c4129f9dcdc73b03068ae6ad894 100644 (file)
@@ -4,6 +4,7 @@ tests/test-truncl.c
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
index f46fffa19a423f4d9e64d279f049adb148539d28..88e5b46eb075f47f86f7ec6a984c302a37f6f23a 100644 (file)
@@ -7,6 +7,7 @@ m4/locale-fr.m4
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 gt_LOCALE_FR
index 221ccd1090a4a78f4f708e1d5f9ae8b1c6a87c31..bf4bd342a5dede0b495b96716f61a76fbdf3ddf4 100644 (file)
@@ -4,6 +4,7 @@ tests/nan.h
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
index 3b45e44cf1f783b54165b72ffe94aa3af9a8ceb7..f099bd6ce18ed31e919b0c80f14bbd6ade7bd79e 100644 (file)
@@ -6,6 +6,7 @@ tests/nan.h
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 AC_DEFINE([CHECK_VSNPRINTF_POSIX], 1,
index e48d5aef5bcc91cdcfd2d6b514c6f4d4016b6299..2d052e9ac9ecd800b524a22f02923f230eae0ba7 100644 (file)
@@ -5,6 +5,7 @@ tests/nan.h
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
index 80ff75ba667eb4c1cbe5bef91ab96464946c8b34..2fa6ca12d7491ee1d9678b27f21ce9cf561a08c9 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@ main ()
 
   /* Zero.  */
   ASSERT (ceill (0.0L) == 0.0L);
-  ASSERT (ceill (-zero) == 0.0L);
+  ASSERT (ceill (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (ceill (0.3L) == 1.0L);
   ASSERT (ceill (0.7L) == 1.0L);
index 49cc8c251732603806566075179cc224033ac41f..f090c9cb2f562143503dac82568a3f387caf5be4 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@ main ()
 
   /* Zero.  */
   ASSERT (floorl (0.0L) == 0.0L);
-  ASSERT (floorl (-zero) == 0.0L);
+  ASSERT (floorl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (floorl (0.3L) == 0.0L);
   ASSERT (floorl (0.7L) == 0.0L);
index a91afce46b05a38b84cde574d19261d79ac052e1..f98bf513139c348d1f8f98eac58b4d97c16979e4 100644 (file)
@@ -57,9 +57,9 @@
 # define MIN_NORMAL_EXP LDBL_MIN_EXP
 #endif
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 static long double
 my_ldexp (long double x, int d)
@@ -117,7 +117,7 @@ main ()
   { /* Negative zero.  */
     int exp = -9999;
     long double mantissa;
-    x = -zero;
+    x = minus_zero;
     mantissa = frexpl (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
index ed3e8275135fd8285ea3c6ba670a5a5153792117..bb925cb1469995fe990c55751c21b34f2e7b2f68 100644 (file)
@@ -48,9 +48,9 @@ float zerof = 0.0f;
    So we use -zero instead.  */
 double zerod = 0.0;
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zerol = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 static void
 test_float (void)
@@ -146,7 +146,7 @@ test_long_double (void)
   ASSERT (!isnan (-2.718e30L));
   ASSERT (!isnan (-2.718e-30L));
   ASSERT (!isnan (0.0L));
-  ASSERT (!isnan (-zerol));
+  ASSERT (!isnan (minus_zerol));
   /* Infinite values.  */
   ASSERT (!isnan (1.0L / 0.0L));
   ASSERT (!isnan (-1.0L / 0.0L));
index d89719031d5e34bafee5d827427c89e6156c46b8..13154758bb725a1649ac0a5d42fcdc7b0b60c385 100644 (file)
@@ -33,9 +33,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -53,7 +53,7 @@ main ()
   ASSERT (!isnanl (-2.718e30L));
   ASSERT (!isnanl (-2.718e-30L));
   ASSERT (!isnanl (0.0L));
-  ASSERT (!isnanl (-zero));
+  ASSERT (!isnanl (minus_zero));
   /* Infinite values.  */
   ASSERT (!isnanl (1.0L / 0.0L));
   ASSERT (!isnanl (-1.0L / 0.0L));
index 322c063581c5ee08eb8727d014c752162e8f2cad..4b5ea32462d4ac3512373142ee47621656fe9531 100644 (file)
@@ -39,9 +39,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -82,7 +82,7 @@ main ()
   }
 
   { /* Negative zero.  */
-    x = -zero;
+    x = minus_zero;
     y = ldexpl (x, 0); ASSERT (y == x); ASSERT (signbit (x));
     y = ldexpl (x, 5); ASSERT (y == x); ASSERT (signbit (x));
     y = ldexpl (x, -5); ASSERT (y == x); ASSERT (signbit (x));
index ae4d3464b2f1ac220b8102ba47954bd7ab476b62..88cb854e79b322c27f28bd0426722d75c111b812 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -40,9 +41,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -53,7 +54,7 @@ main ()
 
   /* Zero.  */
   ASSERT (roundl (0.0L) == 0.0L);
-  ASSERT (roundl (-zero) == 0.0L);
+  ASSERT (roundl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (roundl (0.3L) == 0.0L);
   ASSERT (roundl (0.5L) == 1.0L);
index 95ba61305c95667bfc84f3eb5625014456c2676d..94cab376721c68bfe087e4b064e29c76df47532c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,6 +41,16 @@ float zerof = 0.0f;
 double zerod = 0.0;
 long double zerol = 0.0L;
 
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
+   So we use -zerof instead.  */
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
+   So we use -zerod instead.  */
+
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+
 static void
 test_signbitf ()
 {
@@ -140,10 +151,10 @@ test_signbitl ()
   ASSERT (signbit (-2.718e-30L));
   /* Zeros.  */
   ASSERT (!signbit (0.0L));
-  if (1.0L / -zerol < 0)
-    ASSERT (signbit (-zerol));
+  if (1.0L / minus_zerol < 0)
+    ASSERT (signbit (minus_zerol));
   else
-    ASSERT (!signbit (-zerol));
+    ASSERT (!signbit (minus_zerol));
   /* Infinite values.  */
   ASSERT (!signbit (1.0L / 0.0L));
   ASSERT (signbit (-1.0L / 0.0L));
index f603133ad5d4e665c3932c284e0a56f66ebcd054..58dfbe287b0b6d1dd6a2fdd3483f9a6015142392 100644 (file)
@@ -28,12 +28,12 @@ have_minus_zero ()
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod instead.  */
 double zerod = 0.0;
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zerol = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -444,7 +444,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%La %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%La %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1146,7 +1146,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lf %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lf %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1513,7 +1513,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%LF %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%LF %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -2015,7 +2015,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Le %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Le %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
              || strcmp (result, "-0.000000e+000 33") == 0);
@@ -2668,7 +2668,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lg %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lg %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
     ASSERT (retval == strlen (result));
index ce87a3a1a9e56e280169f50b957c6f0c45f2363c..3caf49fe0570c65743c521c5d268498a991d0db9 100644 (file)
@@ -28,12 +28,12 @@ have_minus_zero ()
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod instead.  */
 double zerod = 0.0;
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zerol = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -430,7 +430,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%La %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%La %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1132,7 +1132,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lf %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Lf %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1499,7 +1499,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%LF %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%LF %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -2001,7 +2001,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Le %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Le %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
              || strcmp (result, "-0.000000e+000 33") == 0);
@@ -2654,7 +2654,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lg %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Lg %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
     ASSERT (retval == strlen (result));
index 3ea856a994cfb91aaecc8aed320249447ce22700..384300fc6d19be030038bbcdc31b3cf65543c582 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   while (0)
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zero = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@ main ()
 
   /* Zero.  */
   ASSERT (truncl (0.0L) == 0.0L);
-  ASSERT (truncl (-zero) == 0.0L);
+  ASSERT (truncl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (truncl (0.3L) == 0.0L);
   ASSERT (truncl (0.7L) == 0.0L);
index 1a6054a0b8cbac0e32a81ccd56b5a781b811563c..aa537fbd74dd4e6da5bb28064db1126578eaf7be 100644 (file)
@@ -53,12 +53,12 @@ have_minus_zero ()
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod instead.  */
 double zerod = 0.0;
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zerol = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -539,7 +539,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%La %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%La %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1351,7 +1351,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lf %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lf %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1798,7 +1798,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%LF %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%LF %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2372,7 +2372,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Le %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Le %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -3127,7 +3127,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lg %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lg %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
index e0465893a5f74908a0d6a086d56694f682cdf000..703b24f188960b38bc1e0fa2e918d59ba94d52a0 100644 (file)
@@ -53,12 +53,12 @@ have_minus_zero ()
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod instead.  */
 double zerod = 0.0;
 
-/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
-   So we use -zero instead.  */
-long double zerol = 0.0L;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -520,7 +520,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%La %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%La %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1332,7 +1332,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Lf %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Lf %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1779,7 +1779,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%LF %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%LF %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2353,7 +2353,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Le %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Le %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -3108,7 +3108,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Lg %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Lg %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);