1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

rational.c: use rb_num_zerodiv instead of rb_raise_zerodiv

* rational.c (rb_raize_zerodiv): replace by rb_num_zerodiv.
  Author: Tadashi Saito <tad.a.digger@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2016-11-12 11:52:09 +00:00
parent f40607d15d
commit 81f16bf32f

View file

@ -400,8 +400,6 @@ nurat_s_alloc(VALUE klass)
return nurat_s_new_internal(klass, ZERO, ONE);
}
#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
#if 0
static VALUE
nurat_s_new_bang(int argc, VALUE *argv, VALUE klass)
@ -425,7 +423,7 @@ nurat_s_new_bang(int argc, VALUE *argv, VALUE klass)
den = f_negate(den);
}
else if (INT_ZERO_P(den)) {
rb_raise_zerodiv();
rb_num_zerodiv();
}
break;
}
@ -480,7 +478,7 @@ nurat_canonicalize(VALUE *num, VALUE *den)
*den = f_negate(*den);
}
else if (INT_ZERO_P(*den)) {
rb_raise_zerodiv();
rb_num_zerodiv();
}
}
@ -903,7 +901,7 @@ nurat_div(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
if (f_zero_p(other))
rb_raise_zerodiv();
rb_num_zerodiv();
{
get_dat1(self);
@ -916,7 +914,7 @@ nurat_div(VALUE self, VALUE other)
return DBL2NUM(nurat_to_double(self) / RFLOAT_VALUE(other));
else if (RB_TYPE_P(other, T_RATIONAL)) {
if (f_zero_p(other))
rb_raise_zerodiv();
rb_num_zerodiv();
{
get_dat2(self, other);
@ -1009,7 +1007,7 @@ nurat_expt(VALUE self, VALUE other)
}
else if (INT_ZERO_P(dat->num)) {
if (f_negative_p(other)) {
rb_raise_zerodiv();
rb_num_zerodiv();
}
else {
return f_rational_new_bang1(CLASS_OF(self), ZERO);