diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-12 00:08:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-12 00:08:44 +0000 |
commit | e9631456a8455e302ac0459fbe0a9a6bc53eb62a (patch) | |
tree | fdde8c70853d88937bcf8813f1bece538f3d6634 /numeric.c | |
parent | 7a55395c5710625a8a60934061fc204540701644 (diff) | |
download | ruby-e9631456a8455e302ac0459fbe0a9a6bc53eb62a.tar.gz |
numeric.c: common expressions
* numeric.c (flo_pow): extract common expressions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1073,24 +1073,25 @@ flo_divmod(VALUE x, VALUE y) static VALUE flo_pow(VALUE x, VALUE y) { + double dx, dy; if (RB_TYPE_P(y, T_FIXNUM)) { - return DBL2NUM(pow(RFLOAT_VALUE(x), (double)FIX2LONG(y))); + dx = RFLOAT_VALUE(x); + dy = (double)FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { - return DBL2NUM(pow(RFLOAT_VALUE(x), rb_big2dbl(y))); + dx = RFLOAT_VALUE(x); + dy = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { - { - double dx = RFLOAT_VALUE(x); - double dy = RFLOAT_VALUE(y); - if (dx < 0 && dy != round(dy)) - return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y); - return DBL2NUM(pow(dx, dy)); - } + dx = RFLOAT_VALUE(x); + dy = RFLOAT_VALUE(y); + if (dx < 0 && dy != round(dy)) + return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y); } else { return rb_num_coerce_bin(x, y, rb_intern("**")); } + return DBL2NUM(pow(dx, dy)); } /* |