2001-03-06 03:17:54 -05:00
|
|
|
/* public domain rewrite of isinf(3) */
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
#ifdef __osf__
|
|
|
|
|
|
|
|
#define _IEEE 1
|
|
|
|
#include <nan.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
isinf(n)
|
|
|
|
double n;
|
|
|
|
{
|
2003-12-20 10:45:15 -05:00
|
|
|
if (IsNANorINF(n) && IsINF(n)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
1999-08-13 01:45:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-12-20 10:45:15 -05:00
|
|
|
|
|
|
|
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
|
|
|
|
|
|
|
|
#ifdef HAVE_IEEEFP_H
|
|
|
|
#include <ieeefp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
isinf(n)
|
|
|
|
double n;
|
|
|
|
{
|
2003-12-21 05:30:24 -05:00
|
|
|
return (!finite(n) && !isnan(n));
|
2003-12-20 10:45:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#else
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static double zero() { return 0.0; }
|
|
|
|
static double one() { return 1.0; }
|
|
|
|
static double inf() { return one() / zero(); }
|
|
|
|
|
|
|
|
int
|
|
|
|
isinf(n)
|
|
|
|
double n;
|
|
|
|
{
|
|
|
|
static double pinf = 0.0;
|
|
|
|
static double ninf = 0.0;
|
|
|
|
|
|
|
|
if (pinf == 0.0) {
|
|
|
|
pinf = inf();
|
|
|
|
ninf = -pinf;
|
|
|
|
}
|
|
|
|
return memcmp(&n, &pinf, sizeof n) == 0
|
|
|
|
|| memcmp(&n, &ninf, sizeof n) == 0;
|
|
|
|
}
|
|
|
|
#endif
|
2003-12-20 10:45:15 -05:00
|
|
|
#endif
|