Remove useless code from do_divide
authorMark H Weaver <mhw@netris.org>
Wed, 26 Jan 2011 07:50:03 +0000 (02:50 -0500)
committerAndy Wingo <wingo@pobox.com>
Fri, 28 Jan 2011 11:26:23 +0000 (12:26 +0100)
* libguile/numbers.c (do_divide): Remove code which handled a case
  that never occurs: a zero bignum.

libguile/numbers.c

index 22ec174..a85a484 100644 (file)
@@ -5124,47 +5124,33 @@ do_divide (SCM x, SCM y, int inexact)
        }
       else if (SCM_BIGP (y))
        {
-         int y_is_zero = (mpz_sgn (SCM_I_BIG_MPZ (y)) == 0);
-         if (y_is_zero)
+         /* big_x / big_y */
+         if (inexact)
            {
-#ifndef ALLOW_DIVIDE_BY_EXACT_ZERO
-             scm_num_overflow (s_divide);
-#else
-             int sgn = mpz_sgn (SCM_I_BIG_MPZ (x));
-             scm_remember_upto_here_1 (x);
-             return (sgn == 0) ? scm_nan () : scm_inf ();
-#endif
+             /* It's easily possible for the ratio x/y to fit a double
+                but one or both x and y be too big to fit a double,
+                hence the use of mpq_get_d rather than converting and
+                dividing.  */
+             mpq_t q;
+             *mpq_numref(q) = *SCM_I_BIG_MPZ (x);
+             *mpq_denref(q) = *SCM_I_BIG_MPZ (y);
+             return scm_from_double (mpq_get_d (q));
            }
          else
            {
-             /* big_x / big_y */
-              if (inexact)
-                {
-                  /* It's easily possible for the ratio x/y to fit a double
-                     but one or both x and y be too big to fit a double,
-                     hence the use of mpq_get_d rather than converting and
-                     dividing.  */
-                  mpq_t q;
-                  *mpq_numref(q) = *SCM_I_BIG_MPZ (x);
-                  *mpq_denref(q) = *SCM_I_BIG_MPZ (y);
-                  return scm_from_double (mpq_get_d (q));
-                }
-              else
-                {
-                  int divisible_p = mpz_divisible_p (SCM_I_BIG_MPZ (x),
-                                                     SCM_I_BIG_MPZ (y));
-                  if (divisible_p)
-                    {
-                      SCM result = scm_i_mkbig ();
-                      mpz_divexact (SCM_I_BIG_MPZ (result),
-                                    SCM_I_BIG_MPZ (x),
-                                    SCM_I_BIG_MPZ (y));
-                      scm_remember_upto_here_2 (x, y);
-                      return scm_i_normbig (result);
-                    }
-                  else
-                    return scm_i_make_ratio (x, y);
-                }
+             int divisible_p = mpz_divisible_p (SCM_I_BIG_MPZ (x),
+                                                SCM_I_BIG_MPZ (y));
+             if (divisible_p)
+               {
+                 SCM result = scm_i_mkbig ();
+                 mpz_divexact (SCM_I_BIG_MPZ (result),
+                               SCM_I_BIG_MPZ (x),
+                               SCM_I_BIG_MPZ (y));
+                 scm_remember_upto_here_2 (x, y);
+                 return scm_i_normbig (result);
+               }
+             else
+               return scm_i_make_ratio (x, y);
            }
        }
       else if (SCM_REALP (y))