2001-03-06 11:17:54 +03:00
|
|
|
/* public domain rewrite of isinf(3) */
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
#ifdef __osf__
|
|
|
|
|
|
|
|
#define _IEEE 1
|
|
|
|
#include <nan.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
isinf(n)
|
|
|
|
double n;
|
|
|
|
{
|
2003-12-20 18:45:15 +03:00
|
|
|
if (IsNANorINF(n) && IsINF(n)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
1999-08-13 09:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-12-20 18:45:15 +03:00
|
|
|
|
|
|
|
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
|
|
|
|
|
|
|
|
#ifdef HAVE_IEEEFP_H
|
|
|
|
#include <ieeefp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
isinf(n)
|
|
|
|
double n;
|
|
|
|
{
|
2003-12-21 13:30:24 +03:00
|
|
|
return (!finite(n) && !isnan(n));
|
2003-12-20 18:45:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
1999-08-13 09: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 18:45:15 +03:00
|
|
|
#endif
|