aboutsummaryrefslogtreecommitdiff
path: root/src/backend/port/isinf.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-02-02 00:04:08 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-02-02 00:04:08 +0000
commite6e364088ac5c980e3fb99300ba74cc26296000b (patch)
tree1ba56773b0a04d45921d9019a166d27b378922a5 /src/backend/port/isinf.c
parent79f99a3888ab3e6a934da47b36d912f9723e1415 (diff)
downloadpostgresql-e6e364088ac5c980e3fb99300ba74cc26296000b.tar.gz
postgresql-e6e364088ac5c980e3fb99300ba74cc26296000b.zip
Move all the isinf() stuff from float.c to isinf.c, and build it according to
configure vs port specific #ifdef's...
Diffstat (limited to 'src/backend/port/isinf.c')
-rw-r--r--src/backend/port/isinf.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/src/backend/port/isinf.c b/src/backend/port/isinf.c
index ca5d22bfe5e..6e9d83e600b 100644
--- a/src/backend/port/isinf.c
+++ b/src/backend/port/isinf.c
@@ -1,15 +1,63 @@
-/* $Id: isinf.c,v 1.1 1998/01/15 20:54:37 scrappy Exp $ */
+/* $Id: isinf.c,v 1.2 1998/02/02 00:03:46 scrappy Exp $ */
-#include <ieeefp.h>
#include <math.h>
-
#include "config.h"
+#if HAVE_FPCLASS
+# if HAVE_IEEEFP_H
+# include <ieeefp.h>
+# endif
+int
+isinf(double d)
+{
+ fpclass_t type = fpclass(d);
+
+ switch (type)
+ {
+ case FP_SNAN:
+ case FP_QNAN:
+ case FP_NINF:
+ case FP_PINF:
+ return (1);
+ default:
+ break;
+ }
+ return (0);
+}
+#endif
+#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)
+ return (1);
+ if (fpclass == FP_NEG_INF)
+ return (-1);
+ return (0);
+}
+#endif
+
+#if defined(HAVE_CLASS)
int
isinf(double x)
{
- if((fpclass(x) == FP_PINF) || (fpclass(x) == FP_NINF)) return 1;
- else return 0;
-}
+ int fpclass = class(x);
+ if (fpclass == FP_PLUS_INF)
+ return (1);
+ if (fpclass == FP_MINUS_INF)
+ return (-1);
+ return (0);
+}
+#endif