summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 02:42:26 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 02:42:26 (GMT)
commit8974d5aaa79f42b7366ecd99d74e29d3faf01ab8 (patch)
tree266e8685410055651ea0e3c43a4b95cfae702dfb /rational.c
parent0f1265899513a96acd6119e204df3985f8887a1a (diff)
rational.c: ensure to be Rational
* 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/trunk@42178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/rational.c b/rational.c
index 86c33b5..6cd31e1 100644
--- a/rational.c
+++ b/rational.c
@@ -1285,6 +1285,10 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
return self;
}
+ 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);