diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-17 14:49:10 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-17 14:49:10 +0000 |
commit | cefaa1680c4f7175d4bb0a3c627e6902cd3b9014 (patch) | |
tree | d01b332bd6df8828734fe78a081ca1ed3cf307c0 /rational.c | |
parent | b6849b2502e7f9ea93e5c1dc6a27359a6311f140 (diff) | |
download | ruby-cefaa1680c4f7175d4bb0a3c627e6902cd3b9014.tar.gz |
* rational.c (nurat_coerce): accepts Complex when the imag is
exact zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rational.c b/rational.c index de676dc473..a75235f65f 100644 --- a/rational.c +++ b/rational.c @@ -902,6 +902,10 @@ nurat_coerce(VALUE self, VALUE other) return rb_assoc_new(other, f_to_f(self)); case T_RATIONAL: return rb_assoc_new(other, self); + case T_COMPLEX: + if (k_exact_p(RCOMPLEX(other)->imag) && f_zero_p(RCOMPLEX(other)->imag)) + return rb_assoc_new(f_rational_new_bang1 + (CLASS_OF(self), RCOMPLEX(other)->real), self); } rb_raise(rb_eTypeError, "%s can't be coerced into %s", |