postgresql/src/port/isinf.c

78 lines
1.2 KiB
C
Raw Normal View History

2003-11-12 00:52:45 +01:00
/*-------------------------------------------------------------------------
*
* isinf.c
*
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
2003-11-12 00:52:45 +01:00
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
2010-09-20 22:08:53 +02:00
* src/port/isinf.c
2003-11-12 00:52:45 +01:00
*
*-------------------------------------------------------------------------
*/
#include "c.h"
1999-07-18 22:43:33 +02:00
#include <float.h>
#include <math.h>
1999-07-17 06:00:31 +02:00
2005-10-15 04:49:52 +02:00
#if HAVE_FPCLASS /* this is _not_ HAVE_FP_CLASS, and not typo */
1999-07-18 22:43:33 +02:00
#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)
1999-07-18 22:43:33 +02:00
1999-07-18 22:43:13 +02:00
#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;
}
#elif defined(HAVE_CLASS)
1999-07-18 22:43:13 +02:00
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
2006-10-04 02:30:14 +02:00
1999-07-18 22:43:33 +02:00
#endif