* numbers.c (scm_divide): Fix (/ 0). Thanks to Keith Wright for
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Wed, 21 Nov 2001 23:23:53 +0000 (23:23 +0000)
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Wed, 21 Nov 2001 23:23:53 +0000 (23:23 +0000)
reporting the bug.

THANKS
libguile/ChangeLog
libguile/numbers.c

diff --git a/THANKS b/THANKS
index 75eb8f4..f0c170e 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -23,3 +23,4 @@ For fixes or providing information which led to a fix:
             Ken Raeburn
           Bill Schottstaedt
         Momchil Velikov
+          Keith Wright
index 7b98f27..44bc00c 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-22  Dirk Herrmann  <D.Herrmann@tu-bs.de>
+
+       * numbers.c (scm_divide):  Fix (/ 0).  Thanks to Keith Wright for
+       reporting the bug.
+
 2001-11-21  Marius Vollmer  <mvo@zagadka.ping.de>
 
        * Makefile.am (install-exec-hook): Prepend $(DESTDIR) to filename.
index 4afc157..b6796fa 100644 (file)
@@ -3707,10 +3707,13 @@ scm_divide (SCM x, SCM y)
     if (SCM_UNBNDP (x)) {
       SCM_WTA_DISPATCH_0 (g_divide, s_divide);
     } else if (SCM_INUMP (x)) {
-      if (SCM_EQ_P (x, SCM_MAKINUM (1L)) || SCM_EQ_P (x, SCM_MAKINUM (-1L))) {
+      long xx = SCM_INUM (x);
+      if (xx == 1 || xx == -1) {
        return x;
+      } else if (xx == 0) {
+       scm_num_overflow (s_divide);
       } else {
-       return scm_make_real (1.0 / (double) SCM_INUM (x));
+       return scm_make_real (1.0 / (double) xx);
       }
     } else if (SCM_BIGP (x)) {
       return scm_make_real (1.0 / scm_i_big2dbl (x));