From f2cb79ffee99c3561503ed7a1c107ca3ec6a48a7 Mon Sep 17 00:00:00 2001 From: tadf Date: Fri, 19 Sep 2008 13:55:52 +0000 Subject: * complex.c: uses f_(in)?exact_p macro. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rational.c: ditto. * bignum.c (rb_big_pow): bignum**bignum - should calculate without rational. * lib/complex.rb: should override Math module at most once. * lib/mathn.rb: requires 'cmath' directly. -この行以下は無視されます -- M complex.c M ChangeLog M lib/mathn.rb M lib/complex.rb M bignum.c M rational.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'rational.c') diff --git a/rational.c b/rational.c index c6c9b91ead..d8af04c61b 100644 --- a/rational.c +++ b/rational.c @@ -213,6 +213,9 @@ k_rational_p(VALUE x) return f_kind_of_p(x, rb_cRational); } +#define k_exact_p(x) (!k_float_p(x)) +#define k_inexact_p(x) k_float_p(x) + #ifndef NDEBUG #define f_gcd f_gcd_orig #endif @@ -773,7 +776,7 @@ nurat_fdiv(VALUE self, VALUE other) static VALUE nurat_expt(VALUE self, VALUE other) { - if (f_zero_p(other)) + if (k_exact_p(other) && f_zero_p(other)) return f_rational_new_bang1(CLASS_OF(self), ONE); if (k_rational_p(other)) { @@ -1403,7 +1406,7 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) switch (TYPE(a1)) { case T_COMPLEX: - if (k_float_p(RCOMPLEX(a1)->image) || !f_zero_p(RCOMPLEX(a1)->image)) { + if (k_inexact_p(RCOMPLEX(a1)->image) || !f_zero_p(RCOMPLEX(a1)->image)) { VALUE s = f_to_s(a1); rb_raise(rb_eRangeError, "can't accept %s", StringValuePtr(s)); @@ -1413,7 +1416,7 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) switch (TYPE(a2)) { case T_COMPLEX: - if (k_float_p(RCOMPLEX(a2)->image) || !f_zero_p(RCOMPLEX(a2)->image)) { + if (k_inexact_p(RCOMPLEX(a2)->image) || !f_zero_p(RCOMPLEX(a2)->image)) { VALUE s = f_to_s(a2); rb_raise(rb_eRangeError, "can't accept %s", StringValuePtr(s)); -- cgit v1.2.3