From 701615379db12dcab080de9d42576e5ee5a75f75 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 21 Jun 2009 10:34:14 +0000 Subject: merges r23727 from trunk into ruby_1_9_1. -- * rational.c (nurat_coerce): accepts Complex when the imag is exact zero. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ rational.c | 4 ++++ version.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fd27a7f01d..cd8dd30c41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 17 23:46:08 2009 Tadayoshi Funaba + + * rational.c (nurat_coerce): accepts Complex when the imag is + exact zero. + Wed Jun 17 16:57:40 2009 Yukihiro Matsumoto * load.c (rb_f_require): RDoc updated. a patch from Run Paint Run diff --git a/rational.c b/rational.c index 6d31c542ad..6e35573eb4 100644 --- a/rational.c +++ b/rational.c @@ -904,6 +904,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", diff --git a/version.h b/version.h index 8d3a71efa7..496b63cae9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-05-22" -#define RUBY_PATCHLEVEL 186 +#define RUBY_PATCHLEVEL 187 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit v1.2.3