* lib/math.in.h (NAN): Define if missing.
* tests/test-math.c (main): Test it.
* doc/posix-headers/math.texi (math.h): Document this.
* lib/isnan.c (rpl_isnand): Use it.
* tests/test-ceilf1.c (NaN): Delete, and use NAN instead.
* tests/test-floorf1.c (NaN): Likewise.
* tests/test-frexp.c (NaN): Likewise.
* tests/test-isnand.c (NaN): Likewise.
* tests/test-isnanf.c (NaN): Likewise.
* tests/test-round1.c (NaN): Likewise.
* tests/test-roundf1.c (NaN): Likewise.
* tests/test-snprintf-posix.h (NaN): Likewise.
* tests/test-sprintf-posix.h (NaN): Likewise.
* tests/test-trunc1.c (NaN): Likewise.
* tests/test-truncf1.c (NaN): Likewise.
* tests/test-vasnprintf-posix.c (NaN): Likewise.
* tests/test-vasprintf-posix.c (NaN): Likewise.
* modules/isnand-nolibm (Depends-on): Add math.
* modules/isnanf-nolibm (Depends-on): Likewise.
* modules/isnanl (Depends-on): Likewise.
* modules/isnanl-nolibm (Depends-on): Likewise.
* modules/snprintf-posix-tests (Depends-on): Likewise.
* modules/sprintf-posix-tests (Depends-on): Likewise.
* modules/vsnprintf-posix-tests (Depends-on): Likewise.
* modules/vsprintf-posix-tests (Depends-on): Likewise.
* modules/vasnprintf-posix-tests (Depends-on): Likewise.
* modules/vasprintf-posix-tests (Depends-on): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
+2008-03-31 Eric Blake <ebb9@byu.net>
+
+ Guarantee a definition of NAN.
+ * lib/math.in.h (NAN): Define if missing.
+ * tests/test-math.c (main): Test it.
+ * doc/posix-headers/math.texi (math.h): Document this.
+ * lib/isnan.c (rpl_isnand): Use it.
+ * tests/test-ceilf1.c (NaN): Delete, and use NAN instead.
+ * tests/test-floorf1.c (NaN): Likewise.
+ * tests/test-frexp.c (NaN): Likewise.
+ * tests/test-isnand.c (NaN): Likewise.
+ * tests/test-isnanf.c (NaN): Likewise.
+ * tests/test-round1.c (NaN): Likewise.
+ * tests/test-roundf1.c (NaN): Likewise.
+ * tests/test-snprintf-posix.h (NaN): Likewise.
+ * tests/test-sprintf-posix.h (NaN): Likewise.
+ * tests/test-trunc1.c (NaN): Likewise.
+ * tests/test-truncf1.c (NaN): Likewise.
+ * tests/test-vasnprintf-posix.c (NaN): Likewise.
+ * tests/test-vasprintf-posix.c (NaN): Likewise.
+ * modules/isnand-nolibm (Depends-on): Add math.
+ * modules/isnanf-nolibm (Depends-on): Likewise.
+ * modules/isnanl (Depends-on): Likewise.
+ * modules/isnanl-nolibm (Depends-on): Likewise.
+ * modules/snprintf-posix-tests (Depends-on): Likewise.
+ * modules/sprintf-posix-tests (Depends-on): Likewise.
+ * modules/vsnprintf-posix-tests (Depends-on): Likewise.
+ * modules/vsprintf-posix-tests (Depends-on): Likewise.
+ * modules/vasnprintf-posix-tests (Depends-on): Likewise.
+ * modules/vasprintf-posix-tests (Depends-on): Likewise.
+
2008-03-31 Bruno Haible <bruno@clisp.org>
* tests/test-strtod.c (main): Update results for OSF/1 platforms.
Portability problems fixed by Gnulib:
@itemize
+@item
+Some platforms do not provide a definition of NAN:
+Solaris 8.
+
@end itemize
Portability problems not fixed by Gnulib:
@itemize
+NAN is not a compile time constant with some broken compilers:
+Compaq (ex-DEC) C 6.4
@end itemize
#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 = zero / zero;
+ nan.value = NAN;
# else
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);
/* A GNU-like <math.h>.
- Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 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
#endif
+/* POSIX allows platforms that don't support NAN. But all major
+ machines in the past 15 years have supported something close to
+ IEEE NaN, so we define this unconditionally. */
+#ifndef NAN
+ /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
+# ifdef __DECC
+static float
+_NaN ()
+{
+ static float zero = 0.0f;
+ return zero / zero;
+}
+# define NAN (_NaN())
+# else
+# define NAN (0.0f / 0.0f)
+# endif
+#endif
+
/* Write x as
x = mantissa * 2^exp
where
Depends-on:
fpieee
+math
configure.ac:
gl_FUNC_ISNAND_NO_LIBM
Depends-on:
fpieee
+math
configure.ac:
gl_FUNC_ISNANF_NO_LIBM
Depends-on:
float
fpieee
+math
configure.ac:
gl_FUNC_ISNANL
Depends-on:
float
fpieee
+math
configure.ac:
gl_FUNC_ISNANL_NO_LIBM
tests/test-snprintf.c
Depends-on:
+math
stdint
configure.ac:
tests/test-sprintf-posix.h
Depends-on:
+math
stdint
configure.ac:
m4/locale-fr.m4
Depends-on:
+math
stdint
configure.ac:
tests/test-vasprintf-posix.c
Depends-on:
+math
stdint
configure.ac:
tests/test-vsnprintf.c
Depends-on:
+math
stdint
configure.ac:
tests/test-sprintf-posix.h
Depends-on:
+math
stdint
configure.ac:
/* Test of rounding towards positive infinity.
- Copyright (C) 2007 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
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static float
-NaN ()
-{
- static float zero = 0.0f;
- return zero / zero;
-}
-#else
-# define NaN() (0.0f / 0.0f)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
/* Test of rounding towards negative infinity.
- Copyright (C) 2007 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
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static float
-NaN ()
-{
- static float zero = 0.0f;
- return zero / zero;
-}
-#else
-# define NaN() (0.0f / 0.0f)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
static double
my_ldexp (double x, int d)
{
{ /* NaN. */
int exp = -9999;
double mantissa;
- x = NaN ();
+ x = NAN;
mantissa = frexp (x, &exp);
ASSERT (isnand (mantissa));
}
#include "isnand.h"
#include <limits.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
int
main ()
{
ASSERT (!isnand (1.0 / 0.0));
ASSERT (!isnand (-1.0 / 0.0));
/* Quiet NaN. */
- ASSERT (isnand (NaN ()));
+ ASSERT (isnand (NAN));
#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 = NAN;
# 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 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>
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static float
-NaN ()
-{
- static float zero = 0.0f;
- return zero / zero;
-}
-#else
-# define NaN() (0.0f / 0.0f)
-#endif
-
int
main ()
{
ASSERT (!isnanf (1.0f / 0.0f));
ASSERT (!isnanf (-1.0f / 0.0f));
/* Quiet NaN. */
- ASSERT (isnanf (NaN ()));
+ ASSERT (isnanf (NAN));
#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 = NAN;
# if FLT_EXPBIT0_BIT > 0
m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1);
# else
/* Test of <math.h> substitute.
- Copyright (C) 2007 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 <math.h>
+#ifndef NAN
+# error NAN should be defined
+choke me
+#endif
+
int
main ()
{
- return 0;
+ double d = NAN;
+ return d == d;
}
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 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
/* Test of rounding to nearest, breaking ties away from zero.
- Copyright (C) 2007 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
- the Free Software Foundation; either version 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static float
-NaN ()
-{
- static float zero = 0.0f;
- return zero / zero;
-}
-#else
-# define NaN() (0.0f / 0.0f)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
+#include <math.h>
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
}
return 0;
}
-
+
static void
test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
{
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%a %d", NaN (), 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%a %d", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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. */
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
+#include <math.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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
/* Test of rounding towards zero.
- Copyright (C) 2007 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
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static float
-NaN ()
-{
- static float zero = 0.0f;
- return zero / zero;
-}
-#else
-# define NaN() (0.0f / 0.0f)
-#endif
-
int
main ()
{
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 (NAN)));
return 0;
}
#include "vasnprintf.h"
#include <float.h>
+#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
have_minus_zero ()
}
return 0;
}
-
+
static void
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%a %d", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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>
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
have_minus_zero ()
}
return 0;
}
-
+
static void
test_function (int (*my_asprintf) (char **, const char *, ...))
{
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%a %d", NaN (), 33, 44, 55);
+ my_asprintf (&result, "%a %d", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 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", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)