* complex.c (nucomp_int_check): function for DRY real check.

* complex.c (nucomp_{add,sub,mul,div,expt}): use rb_num_coerce_bin().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-04-03 12:55:27 +00:00
parent b916c39db4
commit 5d6602c44e
3 changed files with 33 additions and 64 deletions

View file

@ -425,7 +425,7 @@ f_rational_new_bang2(VALUE klass, VALUE x, VALUE y)
#define f_unify_p(klass) rb_const_defined(klass, id_Unify)
static inline void
inline static void
nurat_int_check(VALUE num)
{
switch (TYPE(num)) {
@ -880,7 +880,7 @@ nurat_expt(VALUE self, VALUE other)
case T_RATIONAL:
return f_expt(f_to_f(self), other);
default:
return rb_num_coerce_bin(self, other, rb_intern("**"));
return rb_num_coerce_bin(self, other, id_expt);
}
}
@ -917,7 +917,7 @@ nurat_cmp(VALUE self, VALUE other)
return f_cmp(f_sub(num1, num2), ZERO);
}
default:
return rb_num_coerce_bin(self, other, rb_intern("<=>"));
return rb_num_coerce_bin(self, other, id_cmp);
}
}