2003-11-12 00:52:45 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* isinf.c
|
|
|
|
*
|
2015-01-06 17:43:47 +01:00
|
|
|
* Portions Copyright (c) 1996-2015, 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
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1998-01-15 21:54:52 +01:00
|
|
|
|
2001-08-24 16:07:50 +02:00
|
|
|
#include "c.h"
|
1999-07-18 22:43:33 +02:00
|
|
|
|
2004-09-30 18:38:39 +02:00
|
|
|
#include <float.h>
|
2001-08-24 16:07:50 +02:00
|
|
|
#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
|
|
|
|
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
|
|
|
}
|
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
|
1998-02-26 05:46:47 +01:00
|
|
|
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
|
|
|
}
|
1999-12-16 02:25:23 +01:00
|
|
|
#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
|