changeset 16787:3ad557e686b9

<float.h>: Include if STDC_HEADERS. (IEEE_FLOATING_POINT): New symbol. (float_arith_driver, Fmod): Test for division by 0 only if ! IEEE_FLOATING_POINT.
author Paul Eggert <eggert@twinsun.com>
date Mon, 30 Dec 1996 08:07:51 +0000
parents 8907c00c0cc6
children ffb387a3d054
files src/data.c
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.c	Mon Dec 30 08:07:51 1996 +0000
+++ b/src/data.c	Mon Dec 30 08:07:51 1996 +0000
@@ -35,9 +35,20 @@
 #ifdef LISP_FLOAT_TYPE
 
 #ifdef STDC_HEADERS
+#include <float.h>
 #include <stdlib.h>
 #endif
 
+/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */
+#ifndef IEEE_FLOATING_POINT
+#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
+     && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
+#define IEEE_FLOATING_POINT 1
+#else
+#define IEEE_FLOATING_POINT 0
+#endif
+#endif
+
 /* Work around a problem that happens because math.h on hpux 7
    defines two static variables--which, in Emacs, are not really static,
    because `static' is defined as nothing.  The problem is that they are
@@ -1912,6 +1923,7 @@
   { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin };
 
 extern Lisp_Object float_arith_driver ();
+extern Lisp_Object fmod_float ();
 
 Lisp_Object
 arith_driver (code, nargs, args)
@@ -2029,7 +2041,7 @@
 	    accum = next;
 	  else
 	    {
-	      if (next == 0)
+	      if (! IEEE_FLOATING_POINT && next == 0)
 		Fsignal (Qarith_error, Qnil);
 	      accum /= next;
 	    }
@@ -2136,20 +2148,8 @@
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (y, 1);
 
   if (FLOATP (x) || FLOATP (y))
-    {
-      double f1, f2;
+    return fmod_float (x, y);
 
-      f1 = FLOATP (x) ? XFLOAT (x)->data : XINT (x);
-      f2 = FLOATP (y) ? XFLOAT (y)->data : XINT (y);
-      if (f2 == 0)
-	Fsignal (Qarith_error, Qnil);
-
-      f1 = fmod (f1, f2);
-      /* If the "remainder" comes out with the wrong sign, fix it.  */
-      if (f2 < 0 ? f1 > 0 : f1 < 0)
-	f1 += f2;
-      return (make_float (f1));
-    }
 #else /* not LISP_FLOAT_TYPE */
   CHECK_NUMBER_COERCE_MARKER (x, 0);
   CHECK_NUMBER_COERCE_MARKER (y, 1);