summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-28 14:39:31 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-28 14:39:31 +0000
commit0bd29ba21645e15403ecf72721f0efdd888ea8da (patch)
tree428588c6b04e20282f9b617a1cad3e46ad966127 /rational.c
parent268432c51dae147cebc456aea8ca05842aa78c9a (diff)
* 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 'rational.c')
-rw-r--r--rational.c4
1 files changed, 3 insertions, 1 deletions
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));
}