diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-02 11:30:41 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-02 11:30:41 +0000 |
commit | b13edd512d33d6da7336a10b014daa2af5b9dce1 (patch) | |
tree | bb42b7fe94bbae286550135eb7348dea07b33bd6 /rational.c | |
parent | 297ac0a672480e19ab666f81e47ee097f1d60a29 (diff) |
merge revision(s) 42178: [Backport #8687]
* rational.c (f_round_common): Rational is expected to be returned by
Rational#*, but mathn.rb breaks that assumption. [ruby-core:56177]
[Bug #8687]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@42326 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 8aced2aee8..c66b998506 100644 --- a/rational.c +++ b/rational.c @@ -1230,6 +1230,10 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE)) b = f_expt10(n); s = f_mul(self, b); + if (!k_rational_p(s)) { + s = f_rational_new_bang1(CLASS_OF(self), s); + } + s = (*func)(s); s = f_div(f_rational_new_bang1(CLASS_OF(self), s), b); |