summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-17 02:37:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-17 02:37:32 +0000
commit4fedad85efa84f25cad199eb325d3a300778a046 (patch)
tree98e8c59f05a3a61e4e271d2e1ab100494a59b954 /numeric.c
parent90d065530784a110681ccef1326d63eac9cdc469 (diff)
refine Integer#** and Float#**
* complex.c (rb_dbl_complex_polar): utility function, which returns more precise value in right angle cases. * bignum.c (rb_big_pow): use rb_dbl_complex_polar(). * numeric.c (rb_float_pow, fix_pow): create a Complex by polar form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index 30afc581fe..fe867f9fd3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1276,7 +1276,7 @@ rb_float_pow(VALUE x, VALUE y)
dx = RFLOAT_VALUE(x);
dy = RFLOAT_VALUE(y);
if (dx < 0 && dy != round(dy))
- return num_funcall1(rb_complex_raw1(x), idPow, y);
+ return rb_dbl_complex_polar(pow(-dx, dy), dy);
}
else {
return rb_num_coerce_bin(x, y, idPow);
@@ -4010,7 +4010,7 @@ fix_pow(VALUE x, VALUE y)
if (a == 1) return DBL2NUM(1.0);
{
if (a < 0 && dy != round(dy))
- return num_funcall1(rb_complex_raw1(x), idPow, y);
+ return rb_dbl_complex_polar(pow(-(double)a, dy), dy);
return DBL2NUM(pow((double)a, dy));
}
}