diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-27 03:53:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-27 03:53:43 +0000 |
commit | 8bc02b5ded0ce35097ae13d30c014b99ac861ef0 (patch) | |
tree | b87006a09c9c15b5f8584ec1caf6383d67478c32 /numeric.c | |
parent | 2e774f28a8f9ebec0890c9889d728710d12ef420 (diff) | |
download | ruby-8bc02b5ded0ce35097ae13d30c014b99ac861ef0.tar.gz ruby-8bc02b5ded0ce35097ae13d30c014b99ac861ef0.tar.xz ruby-8bc02b5ded0ce35097ae13d30c014b99ac861ef0.zip |
* numeric.c (int_pow): rb_big_pow() may return other than Bignum.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -2272,9 +2272,11 @@ int_pow(long x, unsigned long y) while (y % 2 == 0) { long x2 = x * x; if (x2 < x || !POSFIXABLE(x2)) { + VALUE v; bignum: - return rb_big_mul(rb_big_pow(rb_int2big(x), LONG2NUM(y)), - rb_int2big(neg ? -z : z)); + v = rb_big_pow(rb_int2big(neg ? -x : x), LONG2NUM(y)); + if (z != 1) v = rb_big_mul(rb_int2big(z), v); + return v; } x = x2; y >>= 1; |