summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c4
1 files changed, 4 insertions, 0 deletions
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);
}