Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / port / isinf.c
blobd268c4ca1430e115e7b576b3c72dca76a4dd7a19
1 /*-------------------------------------------------------------------------
3 * isinf.c
5 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * IDENTIFICATION
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
15 #include "c.h"
17 #include <float.h>
18 #include <math.h>
20 #if HAVE_FPCLASS /* this is _not_ HAVE_FP_CLASS, and not typo */
22 #if HAVE_IEEEFP_H
23 #include <ieeefp.h>
24 #endif
25 int
26 isinf(double d)
28 fpclass_t type = fpclass(d);
30 switch (type)
32 case FP_NINF:
33 case FP_PINF:
34 return 1;
35 default:
36 break;
38 return 0;
40 #else
42 #if defined(HAVE_FP_CLASS) || defined(HAVE_FP_CLASS_D)
44 #if HAVE_FP_CLASS_H
45 #include <fp_class.h>
46 #endif
47 int
48 isinf(x)
49 double x;
51 #if HAVE_FP_CLASS
52 int fpclass = fp_class(x);
53 #else
54 int fpclass = fp_class_d(x);
55 #endif
57 if (fpclass == FP_POS_INF)
58 return 1;
59 if (fpclass == FP_NEG_INF)
60 return -1;
61 return 0;
63 #elif defined(HAVE_CLASS)
64 int
65 isinf(double x)
67 int fpclass = class(x);
69 if (fpclass == FP_PLUS_INF)
70 return 1;
71 if (fpclass == FP_MINUS_INF)
72 return -1;
73 return 0;
75 #endif
77 #endif