summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-19 13:55:52 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-19 13:55:52 +0000
commitf2cb79ffee99c3561503ed7a1c107ca3ec6a48a7 (patch)
tree58ea38242497b45ea49f497d8693123fe508e944 /rational.c
parent396650e0bd353e30b873683f008f92e2aa498971 (diff)
* complex.c: uses f_(in)?exact_p macro.
* 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
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c9
1 files changed, 6 insertions, 3 deletions
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));