diff --git a/src/modules/math/configure.in b/src/modules/math/configure.in
index 9b71f616bd3a648c9693d85ad2c3b088a90c57a4..6e837935f7113236df81427f3126a3c29afd93b9 100644
--- a/src/modules/math/configure.in
+++ b/src/modules/math/configure.in
@@ -1,6 +1,7 @@
-# $Id: configure.in,v 1.4 1998/03/28 13:57:09 grubba Exp $
+# $Id: configure.in,v 1.5 1998/07/22 21:06:42 hubbe Exp $
 AC_INIT(math.c)
 
+
 sinclude(../module_configure.in)
 
 AC_CHECK_LIB(m, floor)
@@ -9,6 +10,8 @@ if test "${ac_cv_lib_m}" = "no" -a "${pike_cv_sys_os}" = "Linux"; then
   LIBS="${LIBS} -lc -lm"
 fi
 
+AC_CHECK_HEADERS(ieeefp.h fp_class.h floatingpoint.h)
+AC_CHECK_FUNCS(fpsetmask)
 
 AC_OUTPUT(Makefile,echo FOO >stamp-h )
 
diff --git a/src/modules/math/math.c b/src/modules/math/math.c
index 1c3875ca112cd59100ddd46597e248f64fa61055..dd4d1a2c249f3a1f59f2bf8224c400d6a538e5cf 100644
--- a/src/modules/math/math.c
+++ b/src/modules/math/math.c
@@ -12,7 +12,15 @@
 #include "module_support.h"
 #include "operators.h"
 
-RCSID("$Id: math.c,v 1.12 1998/07/04 17:02:55 grubba Exp $");
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
+#ifdef HAVE_FLOATINPOINT_H
+#include <floatingpoint.h>
+#endif
+
+RCSID("$Id: math.c,v 1.13 1998/07/22 21:06:42 hubbe Exp $");
 
 #ifndef M_PI
 #define M_PI 3.1415926535897932384626433832795080
@@ -235,6 +243,9 @@ void f_sgn(INT32 args)
 
 void pike_module_init(void)
 {
+#ifdef HAVE_FPSETMASK
+  fpsetmask(0);
+#endif
   add_efun("sin",f_sin,"function(float:float)",0);
   add_efun("asin",f_asin,"function(float:float)",0);
   add_efun("cos",f_cos,"function(float:float)",0);