aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-29 00:45:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-29 00:45:41 +0000
commit36c4713e310d1904ab14d167a2d4e4ad63364f18 (patch)
tree03dd917a9fb6e1980ad4a9d6152be97159ef50c5 /numeric.c
parentc655db52170dafdcf3b0a2237cc2b1ad90cf875a (diff)
downloadruby-36c4713e310d1904ab14d167a2d4e4ad63364f18.tar.gz
rational.c: may be float
* rational.c (f_muldiv): Integer#** can return Rational with Float right now. [ruby-core:89212] [Bug #15175] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index da0bad3211..1dbe1bfb84 100644
--- a/numeric.c
+++ b/numeric.c
@@ -4034,7 +4034,13 @@ fix_pow(VALUE x, VALUE y)
}
if (BIGNUM_NEGATIVE_P(y)) {
if (a == 0) rb_num_zerodiv();
- return rb_rational_raw(INT2FIX(1), rb_int_pow(x, rb_big_uminus(y)));
+ y = rb_int_pow(x, rb_big_uminus(y));
+ if (0 && RB_FLOAT_TYPE_P(y)) {
+ /* Maybe should return a Float */
+ double d = pow((double)a, RFLOAT_VALUE(y));
+ return DBL2NUM(d);
+ }
+ return rb_rational_raw(INT2FIX(1), y);
}
if (a == 0) return INT2FIX(0);
x = rb_int2big(FIX2LONG(x));