+2008-04-01 Bruno Haible <bruno@clisp.org>
+
+ * tests/test-vasnprintf-posix.c: Include nan.h instead of <math.h>.
+ (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+ * modules/vasnprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+
+ * tests/test-vasprintf-posix.c: Include nan.h instead of <math.h>.
+ (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+ * modules/vasprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+
+ * tests/test-snprintf-posix.h: Include nan.h instead of <math.h>.
+ (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+ * modules/snprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+ * modules/vsnprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+
+ * tests/test-sprintf-posix.h: Include nan.h instead of <math.h>.
+ (test_function): Use NaNd, NaNl instead of NAN or 0.0L/0.0L.
+ * modules/sprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+ * modules/vsprintf-posix-tests (Files): Add tests/nan.h.
+ (Depends-on): Remove math.
+
+ * tests/test-round1.c: Include nan.h.
+ (main): Use NaNd instead of NAN.
+ * modules/round-tests (Files): Add tests/nan.h.
+
+ * tests/test-trunc1.c: Include nan.h.
+ (main): Use NaNd instead of NAN.
+ * modules/trunc-tests (Files): Add tests/nan.h.
+
+ * tests/test-roundf1.c: Include nan.h.
+ (main): Use NaNf instead of NAN.
+ * modules/roundf-tests (Files): Add tests/nan.h.
+
+ * tests/test-truncf1.c: Include nan.h.
+ (main): Use NaNf instead of NAN.
+ * modules/truncf-tests (Files): Add tests/nan.h.
+
+ * tests/test-ceilf1.c: Include nan.h.
+ (main): Use NaNf instead of NAN.
+ * modules/ceilf-tests (Files): Add tests/nan.h.
+
+ * tests/test-floorf1.c: Include nan.h.
+ (main): Use NaNf instead of NAN.
+ * modules/floorf-tests (Files): Add tests/nan.h.
+
+ * tests/test-isnanf.c: Include nan.h instead of <math.h>.
+ (main): Use NaNf instead of NAN.
+ * modules/isnanf-nolibm-tests (Files): Add tests/nan.h.
+
+ * tests/test-isnand.c: Include nan.h instead of <math.h>.
+ (main): Use NaNd instead of NAN.
+ * modules/isnand-nolibm-tests (Files): Add tests/nan.h.
+
+ * tests/test-frexp.c: Include nan.h.
+ (main): Use NaNd instead of NAN.
+ * modules/frexp-tests (Files): Add tests/nan.h.
+
+ * lib/isnan.c: Don't include <math.h>.
+ (FUNC): Don't use NAN macro.
+ * modules/isnand-nolibm (Depends-on): Remove math.
+ * modules/isnanf-nolibm (Depends-on): Remove math.
+ * modules/isnanl (Depends-on): Remove math.
+ * modules/isnanl-nolibm (Depends-on): Remove math.
+
+ * tests/nan.h: New file.
+
2008-04-01 Eric Blake <ebb9@byu.net>
Fix typos.
#include <config.h>
#include <float.h>
-#include <math.h>
#include <string.h>
#include "float+.h"
also fails when constant-folding 0.0 / 0.0 even when constant-folding is
not required. The SGI MIPSpro C compiler complains about "floating-point
operation result is out of range". */
+ static DOUBLE zero = L_(0.0);
memory_double nan;
DOUBLE plus_inf = L_(1.0) / L_(0.0);
DOUBLE minus_inf = -L_(1.0) / L_(0.0);
- nan.value = NAN;
+ nan.value = zero / zero;
# else
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);
Files:
tests/test-ceilf1.c
tests/test-ceilf2.c
+tests/nan.h
Depends-on:
float
Files:
tests/test-floorf1.c
tests/test-floorf2.c
+tests/nan.h
Depends-on:
float
Files:
tests/test-frexp.c
+tests/nan.h
Depends-on:
isnand-nolibm
Depends-on:
fpieee
-math
configure.ac:
gl_FUNC_ISNAND_NO_LIBM
Files:
tests/test-isnand.c
+tests/nan.h
Depends-on:
Depends-on:
fpieee
-math
configure.ac:
gl_FUNC_ISNANF_NO_LIBM
Files:
tests/test-isnanf.c
+tests/nan.h
Depends-on:
Depends-on:
float
fpieee
-math
configure.ac:
gl_FUNC_ISNANL
Depends-on:
float
fpieee
-math
configure.ac:
gl_FUNC_ISNANL_NO_LIBM
Files:
tests/test-round1.c
tests/test-round2.c
+tests/nan.h
Depends-on:
isnand-nolibm
tests/test-roundf1.c
tests/test-round2.c
tests/test-roundf2.c
+tests/nan.h
Depends-on:
ceilf
tests/test-snprintf-posix.c
tests/test-snprintf-posix.h
tests/test-snprintf.c
+tests/nan.h
Depends-on:
-math
stdint
configure.ac:
Files:
tests/test-sprintf-posix.c
tests/test-sprintf-posix.h
+tests/nan.h
Depends-on:
-math
stdint
configure.ac:
Files:
tests/test-trunc1.c
tests/test-trunc2.c
+tests/nan.h
Depends-on:
float
Files:
tests/test-truncf1.c
tests/test-truncf2.c
+tests/nan.h
Depends-on:
float
tests/test-vasnprintf-posix.c
tests/test-vasnprintf-posix2.sh
tests/test-vasnprintf-posix2.c
+tests/nan.h
m4/locale-fr.m4
Depends-on:
-math
stdint
configure.ac:
Files:
tests/test-vasprintf-posix.c
+tests/nan.h
Depends-on:
-math
stdint
configure.ac:
tests/test-vsnprintf-posix.c
tests/test-snprintf-posix.h
tests/test-vsnprintf.c
+tests/nan.h
Depends-on:
-math
stdint
configure.ac:
Files:
tests/test-vsprintf-posix.c
tests/test-sprintf-posix.h
+tests/nan.h
Depends-on:
-math
stdint
configure.ac:
--- /dev/null
+/* Macros for not-a-number.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+/* NaNf () returns a 'float' not-a-number. */
+
+/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
+#ifdef __DECC
+static float
+NaNf ()
+{
+ static float zero = 0.0f;
+ return zero / zero;
+}
+#else
+# define NaNf() (0.0f / 0.0f)
+#endif
+
+
+/* NaNd () returns a 'double' not-a-number. */
+
+/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
+#ifdef __DECC
+static double
+NaNd ()
+{
+ static double zero = 0.0;
+ return zero / zero;
+}
+#else
+# define NaNd() (0.0 / 0.0)
+#endif
+
+
+/* NaNl () returns a 'long double' not-a-number. */
+
+#define NaNl() (0.0L / 0.0L)
/* Test of rounding towards positive infinity.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdlib.h>
#include "isnanf.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (ceilf (1.0f / 0.0f) == 1.0f / 0.0f);
ASSERT (ceilf (-1.0f / 0.0f) == -1.0f / 0.0f);
/* NaNs. */
- ASSERT (isnanf (ceilf (NAN)));
+ ASSERT (isnanf (ceilf (NaNf ())));
return 0;
}
/* Test of rounding towards negative infinity.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdlib.h>
#include "isnanf.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (floorf (1.0f / 0.0f) == 1.0f / 0.0f);
ASSERT (floorf (-1.0f / 0.0f) == -1.0f / 0.0f);
/* NaNs. */
- ASSERT (isnanf (floorf (NAN)));
+ ASSERT (isnanf (floorf (NaNf ())));
return 0;
}
#include <stdlib.h>
#include "isnand.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
{ /* NaN. */
int exp = -9999;
double mantissa;
- x = NAN;
+ x = NaNd ();
mantissa = frexp (x, &exp);
ASSERT (isnand (mantissa));
}
#include "isnand.h"
#include <limits.h>
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include "nan.h"
+
#define ASSERT(expr) \
do \
{ \
ASSERT (!isnand (1.0 / 0.0));
ASSERT (!isnand (-1.0 / 0.0));
/* Quiet NaN. */
- ASSERT (isnand (NAN));
+ ASSERT (isnand (NaNd ()));
#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
/* Signalling NaN. */
{
((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
typedef union { double value; unsigned int word[NWORDS]; } memory_double;
memory_double m;
- m.value = NAN;
+ m.value = NaNd ();
# if DBL_EXPBIT0_BIT > 0
m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1);
# else
/* Test of isnanf() substitute.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "isnanf.h"
#include <limits.h>
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include "nan.h"
+
#define ASSERT(expr) \
do \
{ \
ASSERT (!isnanf (1.0f / 0.0f));
ASSERT (!isnanf (-1.0f / 0.0f));
/* Quiet NaN. */
- ASSERT (isnanf (NAN));
+ ASSERT (isnanf (NaNf ()));
#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT
/* Signalling NaN. */
{
((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
typedef union { float value; unsigned int word[NWORDS]; } memory_float;
memory_float m;
- m.value = NAN;
+ m.value = NaNf ();
# if FLT_EXPBIT0_BIT > 0
m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1);
# else
choke me
#endif
+#if 0
+/* Check that NAN expands into a constant expression. */
+static float n = NAN;
+#endif
+
int
main ()
{
#include <stdlib.h>
#include "isnand.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (round (1.0 / 0.0) == 1.0 / 0.0);
ASSERT (round (-1.0 / 0.0) == -1.0 / 0.0);
/* NaNs. */
- ASSERT (isnand (round (NAN)));
+ ASSERT (isnand (round (NaNd ())));
return 0;
}
#include <stdlib.h>
#include "isnanf.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (roundf (1.0 / 0.0f) == 1.0 / 0.0f);
ASSERT (roundf (-1.0 / 0.0f) == -1.0 / 0.0f);
/* NaNs. */
- ASSERT (isnanf (roundf (NAN)));
+ ASSERT (isnanf (roundf (NaNf ())));
return 0;
}
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-#include <math.h>
+#include "nan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%a %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%a %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050a %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050a %d", NaNd (), 33, 44, 55);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
ASSERT (strlen (result) == 50 + 3
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%La %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050La %d", NaNl (), 33, 44, 55);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
ASSERT (strlen (result) == 50 + 3
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%f %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%f %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050f %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050f %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%Lf %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%Lf %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050Lf %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050Lf %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%F %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%F %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%LF %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%LF %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%e %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%e %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050e %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050e %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%Le %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%Le %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050Le %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050Le %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%g %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%g %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050g %d", NAN, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050g %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%Lg %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%Lg %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%050Lg %d", zero / zero, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%050Lg %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-#include <math.h>
+#include "nan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%a %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%a %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050a %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%050a %d", NaNd (), 33, 44, 55);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
ASSERT (strlen (result) == 50 + 3
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_sprintf (result, "%La %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_sprintf (result, "%050La %d", NaNl (), 33, 44, 55);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
ASSERT (strlen (result) == 50 + 3
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%f %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%f %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050f %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%050f %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%Lf %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%Lf %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%050Lf %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%050Lf %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%F %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%F %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%LF %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%LF %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%e %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%e %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050e %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%050e %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%Le %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%Le %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%050Le %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%050Le %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%g %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%g %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050g %d", NAN, 33, 44, 55);
+ my_sprintf (result, "%050g %d", NaNd (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%Lg %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%Lg %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char result[1000];
int retval =
- my_sprintf (result, "%050Lg %d", zero / zero, 33, 44, 55);
+ my_sprintf (result, "%050Lg %d", NaNl (), 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
#include <stdlib.h>
#include "isnand.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (trunc (1.0 / 0.0) == 1.0 / 0.0);
ASSERT (trunc (-1.0 / 0.0) == -1.0 / 0.0);
/* NaNs. */
- ASSERT (isnand (trunc (NAN)));
+ ASSERT (isnand (trunc (NaNd ())));
return 0;
}
/* Test of rounding towards zero.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdlib.h>
#include "isnanf.h"
+#include "nan.h"
#define ASSERT(expr) \
do \
ASSERT (truncf (1.0f / 0.0f) == 1.0f / 0.0f);
ASSERT (truncf (-1.0f / 0.0f) == -1.0f / 0.0f);
/* NaNs. */
- ASSERT (isnanf (truncf (NAN)));
+ ASSERT (isnanf (truncf (NaNf ())));
return 0;
}
#include "vasnprintf.h"
#include <float.h>
-#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "nan.h"
+
#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
#define ASSERT(expr) \
do \
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%a %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%a %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050a %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050a %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%La %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050La %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%f %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%f %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050f %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050f %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%Lf %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%Lf %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050Lf %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050Lf %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%F %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%F %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
}
{ /* NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%LF %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%LF %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%e %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%e %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050e %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050e %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%Le %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%Le %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050Le %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050Le %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%g %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%g %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050g %d", NAN, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050g %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%Lg %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%Lg %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050Lg %d", zero / zero, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050Lg %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
#include <stdio.h>
#include <float.h>
-#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "nan.h"
+
#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
#define ASSERT(expr) \
do \
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%a %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%a %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%050a %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%050a %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_asprintf (&result, "%La %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%050La %d", 0.0L / 0.0L, 33, 44, 55);
+ my_asprintf (&result, "%050La %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%f %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%f %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%050f %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%050f %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%Lf %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%Lf %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%050Lf %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%050Lf %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%F %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%F %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
}
{ /* NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%LF %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%LF %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%e %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%e %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%050e %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%050e %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%Le %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%Le %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%050Le %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%050Le %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%g %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%g %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%050g %d", NAN, 33, 44, 55);
+ my_asprintf (&result, "%050g %d", NaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
}
{ /* NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%Lg %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%Lg %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
}
{ /* FLAG_ZERO with NaN. */
- static long double zero = 0.0L;
char *result;
int retval =
- my_asprintf (&result, "%050Lg %d", zero / zero, 33, 44, 55);
+ my_asprintf (&result, "%050Lg %d", NaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)