summaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-28 13:27:48 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-28 13:27:48 +0000
commit5a50aceb7243c6bd636cb615778214722d0593ab (patch)
treede8fff4d6490579ace7f2d1092ad08970c5b64ae /complex.c
parent3f13d9f0710b22039ec405392ef83ed2f391e8ec (diff)
downloadruby-5a50aceb7243c6bd636cb615778214722d0593ab.tar.gz
ruby-5a50aceb7243c6bd636cb615778214722d0593ab.tar.xz
ruby-5a50aceb7243c6bd636cb615778214722d0593ab.zip
* complex.c (nucomp_expt): convert to a float when the given power
is a bignum. * rational.c (nurat_expt): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/complex.c b/complex.c
index 2a7e602ed..3863e685c 100644
--- a/complex.c
+++ b/complex.c
@@ -227,6 +227,18 @@ k_integer_p(VALUE x)
}
inline static VALUE
+k_fixnum_p(VALUE x)
+{
+ return f_kind_of_p(x, rb_cFixnum);
+}
+
+inline static VALUE
+k_bignum_p(VALUE x)
+{
+ return f_kind_of_p(x, rb_cBignum);
+}
+
+inline static VALUE
k_float_p(VALUE x)
{
return f_kind_of_p(x, rb_cFloat);
@@ -831,7 +843,7 @@ nucomp_expt(VALUE self, VALUE other)
f_mul(dat->imag, m_log_bang(r)));
return f_complex_polar(CLASS_OF(self), nr, ntheta);
}
- if (k_integer_p(other)) {
+ if (k_fixnum_p(other)) {
if (f_gt_p(other, ZERO)) {
VALUE x, z, n;
@@ -862,9 +874,12 @@ nucomp_expt(VALUE self, VALUE other)
if (k_numeric_p(other) && f_real_p(other)) {
VALUE r, theta;
+ if (k_bignum_p(other))
+ rb_warn("in a**b, b may be too big");
+
r = f_abs(self);
theta = f_arg(self);
- return f_complex_polar(CLASS_OF(self), f_expt(r, other),
+ return f_complex_polar(CLASS_OF(self), rb_fexpt(r, other),
f_mul(theta, other));
}
return rb_num_coerce_bin(self, other, id_expt);