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
|
2006-01-05 00:29:48 -05:00
|
|
|
isinf(double n)
|
1999-08-13 01:45:20 -04:00
|
|
|
{
|
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
|
|
|
|
|
2007-06-10 05:30:55 -04:00
|
|
|
#include "ruby/config.h"
|
2003-12-20 10:45:15 -05:00
|
|
|
|
|
|
|
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
|
|
|
|
|
2005-10-13 10:30:54 -04:00
|
|
|
#include <math.h>
|
2003-12-20 10:45:15 -05:00
|
|
|
#ifdef HAVE_IEEEFP_H
|
|
|
|
#include <ieeefp.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-15 07:55:52 -04:00
|
|
|
/*
|
2007-11-13 11:54:27 -05:00
|
|
|
* isinf may be provided only as a macro.
|
|
|
|
* ex. HP-UX, Solaris 10
|
|
|
|
* http://www.gnu.org/software/automake/manual/autoconf/Function-Portability.html
|
|
|
|
*/
|
|
|
|
#ifndef isinf
|
2003-12-20 10:45:15 -05:00
|
|
|
int
|
2006-01-05 00:29:48 -05:00
|
|
|
isinf(double n)
|
2003-12-20 10:45:15 -05:00
|
|
|
{
|
2003-12-21 05:30:24 -05:00
|
|
|
return (!finite(n) && !isnan(n));
|
2003-12-20 10:45:15 -05:00
|
|
|
}
|
2007-11-13 11:54:27 -05:00
|
|
|
#endif
|
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
|
|
|
|
|
2006-01-05 00:29:48 -05:00
|
|
|
static double zero(void) { return 0.0; }
|
|
|
|
static double one (void) { return 1.0; }
|
|
|
|
static double inf (void) { return one() / zero(); }
|
1999-08-13 01:45:20 -04:00
|
|
|
|
|
|
|
int
|
2006-01-05 00:29:48 -05:00
|
|
|
isinf(double n)
|
1999-08-13 01:45:20 -04:00
|
|
|
{
|
|
|
|
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
|