diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-28 14:39:31 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-28 14:39:31 +0000 |
commit | 0bd29ba21645e15403ecf72721f0efdd888ea8da (patch) | |
tree | 428588c6b04e20282f9b617a1cad3e46ad966127 /complex.c | |
parent | 268432c51dae147cebc456aea8ca05842aa78c9a (diff) | |
download | ruby-0bd29ba21645e15403ecf72721f0efdd888ea8da.tar.gz |
* 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).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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); } |