1999-07-16 00:40:16 +02:00
|
|
|
/* $Id: isinf.c,v 1.7 1999/07/15 22:39:38 momjian Exp $ */
|
1998-01-15 21:54:52 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
#include <math.h>
|
1998-01-15 21:54:52 +01:00
|
|
|
|
1998-02-02 01:04:08 +01:00
|
|
|
#if HAVE_FPCLASS
|
1998-02-26 05:46:47 +01:00
|
|
|
#if HAVE_IEEEFP_H
|
|
|
|
#include <ieeefp.h>
|
|
|
|
#endif
|
1998-02-02 01:04:08 +01:00
|
|
|
int
|
|
|
|
isinf(double d)
|
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
fpclass_t type = fpclass(d);
|
1998-02-02 01:04:08 +01:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case FP_NINF:
|
|
|
|
case FP_PINF:
|
1998-09-01 05:29:17 +02:00
|
|
|
return 1;
|
1998-02-02 01:04:08 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-09-01 05:29:17 +02:00
|
|
|
return 0;
|
1998-02-02 01:04:08 +01:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#if defined(HAVE_FP_CLASS) || defined(HAVE_FP_CLASS_D)
|
|
|
|
#if HAVE_FP_CLASS_H
|
|
|
|
#endif
|
|
|
|
int
|
|
|
|
isinf(x)
|
|
|
|
double x;
|
|
|
|
{
|
|
|
|
#if HAVE_FP_CLASS
|
|
|
|
int fpclass = fp_class(x);
|
|
|
|
|
1998-02-17 03:00:12 +01:00
|
|
|
#else
|
1998-02-26 05:46:47 +01:00
|
|
|
int fpclass = fp_class_d(x);
|
|
|
|
|
|
|
|
#endif
|
1998-01-15 21:54:52 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
if (fpclass == FP_POS_INF)
|
1998-09-01 05:29:17 +02:00
|
|
|
return 1;
|
1998-02-02 01:04:08 +01:00
|
|
|
if (fpclass == FP_NEG_INF)
|
1998-09-01 05:29:17 +02:00
|
|
|
return -1;
|
|
|
|
return 0;
|
1998-02-02 01:04:08 +01:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
|
|
|
|
#endif
|
1998-02-02 01:04:08 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CLASS)
|
1998-01-15 21:54:52 +01:00
|
|
|
int
|
|
|
|
isinf(double x)
|
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
int fpclass = class(x);
|
1998-01-15 21:54:52 +01:00
|
|
|
|
1998-02-02 01:04:08 +01:00
|
|
|
if (fpclass == FP_PLUS_INF)
|
1998-09-01 05:29:17 +02:00
|
|
|
return 1;
|
1998-02-02 01:04:08 +01:00
|
|
|
if (fpclass == FP_MINUS_INF)
|
1998-09-01 05:29:17 +02:00
|
|
|
return -1;
|
|
|
|
return 0;
|
1998-02-02 01:04:08 +01:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
|
1998-02-02 01:04:08 +01:00
|
|
|
#endif
|