#include <stdio.h>
#include <string.h>
-#include "isnand.h"
+#include "isnand-nolibm.h"
#define ASSERT(expr) \
do \
} \
while (0)
+/* Avoid requiring -lm just for fabs. */
+#define FABS(d) ((d) < 0.0 ? -(d) : (d))
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
+ So we use -zero instead. */
+double zero = 0.0;
+
int
main ()
{
/* FIXME - gnulib's version is rather inaccurate. It would be
nice to guarantee an exact result, but for now, we settle for a
1-ulp error. */
- ASSERT (abs (result - 0.5) < DBL_EPSILON);
+ ASSERT (FABS (result - 0.5) < DBL_EPSILON);
ASSERT (ptr == input + 2);
ASSERT (errno == 0);
}
/* FIXME - gnulib's version is rather inaccurate. It would be
nice to guarantee an exact result, but for now, we settle for a
1-ulp error. */
- ASSERT (abs (result - 0.5) < DBL_EPSILON);
+ ASSERT (FABS (result - 0.5) < DBL_EPSILON);
ASSERT (ptr == input + 4);
ASSERT (errno == 0);
}
errno = 0;
result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5, OSF/1 4.0 */
+ ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 4.0 */
ASSERT (ptr == input + 2);
ASSERT (errno == 0);
}
errno = 0;
result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (!!signbit (result) == !!signbit (-0.0)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */
+ ASSERT (!!signbit (result) == !!signbit (-zero)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */
ASSERT (ptr == input + 2); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2 */
ASSERT (errno == 0);
}
0 on negative underflow, even though quality of implementation
demands preserving the sign. Disable this test until fixed
glibc is more prevalent. */
- ASSERT (!!signbit (result) == !!signbit (-0.0)); /* glibc-2.3.6, mingw */
+ ASSERT (!!signbit (result) == !!signbit (-zero)); /* glibc-2.3.6, mingw */
#endif
ASSERT (ptr == input + 10);
ASSERT (errno == ERANGE);
errno = 0;
result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5, OSF/1 4.0 */
+ ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 4.0 */
ASSERT (ptr == input + m);
ASSERT (errno == 0);
}