ruby-changes:12058
From: tadf <ko1@a...>
Date: Wed, 17 Jun 2009 23:50:57 +0900 (JST)
Subject: [ruby-changes:12058] Ruby:r23727 (trunk): * rational.c (nurat_coerce): accepts Complex when the imag is
tadf 2009-06-17 23:49:10 +0900 (Wed, 17 Jun 2009) New Revision: 23727 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23727 Log: * rational.c (nurat_coerce): accepts Complex when the imag is exact zero. Modified files: trunk/ChangeLog trunk/rational.c Index: ChangeLog =================================================================== --- ChangeLog (revision 23726) +++ ChangeLog (revision 23727) @@ -1,3 +1,8 @@ +Wed Jun 17 23:46:08 2009 Tadayoshi Funaba <tadf@d...> + + * rational.c (nurat_coerce): accepts Complex when the imag is + exact zero. + Wed Jun 17 21:25:54 2009 Tadayoshi Funaba <tadf@d...> * bignum.c (rb_big_fdiv): checks whether the given second argument Index: rational.c =================================================================== --- rational.c (revision 23726) +++ rational.c (revision 23727) @@ -902,6 +902,10 @@ 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", -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/