diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-02 16:42:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-02 16:42:21 +0000 |
commit | 603f95a0ed37d90854f80393881fb38ab29128a7 (patch) | |
tree | 2f76d289cf541c53cb29dff917569d0846a12613 /numeric.c | |
parent | 25ea4dc6230f3141dcb3b9d04c9124bc07146bca (diff) | |
download | ruby-603f95a0ed37d90854f80393881fb38ab29128a7.tar.gz |
Fix Rational of Float
[ruby-core:89239] [Bug #15189]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -4015,7 +4015,8 @@ fix_pow(VALUE x, VALUE y) } if (b < 0) { if (a == 0) rb_num_zerodiv(); - return rb_rational_raw(INT2FIX(1), rb_int_pow(x, LONG2NUM(-b))); + y = rb_int_pow(x, LONG2NUM(-b)); + goto inverted; } if (b == 0) return INT2FIX(1); @@ -4035,10 +4036,10 @@ fix_pow(VALUE x, VALUE y) if (BIGNUM_NEGATIVE_P(y)) { if (a == 0) rb_num_zerodiv(); y = rb_int_pow(x, rb_big_uminus(y)); - if (0 && RB_FLOAT_TYPE_P(y)) { - /* Maybe should return a Float */ + inverted: + if (RB_FLOAT_TYPE_P(y)) { double d = pow((double)a, RFLOAT_VALUE(y)); - return DBL2NUM(d); + return DBL2NUM(1.0 / d); } return rb_rational_raw(INT2FIX(1), y); } |