summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--complex.c4
-rw-r--r--rational.c4
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 194dff7ed1..d7af8540cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jun 28 23:32:11 2009 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_div): raises ZeroDivisionError immediately
+ when the given second argument is zero.
+
+ * rational.c (nurat_fdiv): never raise even if the given second
+ argument is zero.
+
+ * rational.c (rb_raise_zerodiv): changed the message (zero to 0).
+
Sun Jun 28 22:25:07 2009 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (nucomp_expt): convert to a float when the given power
diff --git a/complex.c b/complex.c
index 3863e685c3..5c2918e082 100644
--- a/complex.c
+++ b/complex.c
@@ -727,6 +727,8 @@ f_divide(VALUE self, VALUE other,
return rb_num_coerce_bin(self, other, id);
}
+#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
+
/*
* call-seq:
* cmp / numeric -> complex
@@ -742,6 +744,8 @@ f_divide(VALUE self, VALUE other,
static VALUE
nucomp_div(VALUE self, VALUE other)
{
+ if (f_zero_p(other))
+ rb_raise_zerodiv();
return f_divide(self, other, f_quo, id_quo);
}
diff --git a/rational.c b/rational.c
index 8b28ac5ad1..8089f4a892 100644
--- a/rational.c
+++ b/rational.c
@@ -321,7 +321,7 @@ nurat_s_alloc(VALUE klass)
return nurat_s_new_internal(klass, ZERO, ONE);
}
-#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by zero")
+#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
#if 0
static VALUE
@@ -867,6 +867,8 @@ nurat_div(VALUE self, VALUE other)
static VALUE
nurat_fdiv(VALUE self, VALUE other)
{
+ if (f_zero_p(other))
+ return f_div(self, f_to_f(other));
return f_to_f(f_div(self, other));
}