postgresql/src/backend/port/isinf.c

68 lines
838 B
C
Raw Normal View History

1999-07-18 22:43:13 +02:00
/* $Id: isinf.c,v 1.11 1999/07/18 20:43:12 momjian Exp $ */
#include <math.h>
1999-07-17 06:00:31 +02:00
#include "config.h"
1999-07-18 22:43:13 +02:00
#if HAVE_FPCLASS
#if HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
int
isinf(double d)
{
fpclass_t type = fpclass(d);
switch (type)
{
case FP_NINF:
case FP_PINF:
1998-09-01 05:29:17 +02:00
return 1;
default:
break;
}
1998-09-01 05:29:17 +02:00
return 0;
}
1999-07-18 22:43:13 +02:00
#else
#if defined(HAVE_FP_CLASS) || defined(HAVE_FP_CLASS_D)
#if HAVE_FP_CLASS_H
#include <fp_class.h>
#endif
int
isinf(x)
double x;
{
#if HAVE_FP_CLASS
int fpclass = fp_class(x);
#else
int fpclass = fp_class_d(x);
#endif
if (fpclass == FP_POS_INF)
1998-09-01 05:29:17 +02:00
return 1;
if (fpclass == FP_NEG_INF)
1998-09-01 05:29:17 +02:00
return -1;
return 0;
}
#endif
1999-07-18 22:43:13 +02:00
#endif
#if defined(HAVE_CLASS)
int
isinf(double x)
{
int fpclass = class(x);
if (fpclass == FP_PLUS_INF)
return 1;
if (fpclass == FP_MINUS_INF)
return -1;
return 0;
}
#endif