* 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
This commit is contained in:
parent
b6849b2502
commit
cefaa1680c
@ -1,3 +1,8 @@
|
|||||||
|
Wed Jun 17 23:46:08 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* rational.c (nurat_coerce): accepts Complex when the imag is
|
||||||
|
exact zero.
|
||||||
|
|
||||||
Wed Jun 17 21:25:54 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
Wed Jun 17 21:25:54 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* bignum.c (rb_big_fdiv): checks whether the given second argument
|
* bignum.c (rb_big_fdiv): checks whether the given second argument
|
||||||
|
@ -902,6 +902,10 @@ nurat_coerce(VALUE self, VALUE other)
|
|||||||
return rb_assoc_new(other, f_to_f(self));
|
return rb_assoc_new(other, f_to_f(self));
|
||||||
case T_RATIONAL:
|
case T_RATIONAL:
|
||||||
return rb_assoc_new(other, self);
|
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",
|
rb_raise(rb_eTypeError, "%s can't be coerced into %s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user