mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (int_pow): rb_big_pow() may return other than Bignum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9d89855052
commit
5d2069cd56
2 changed files with 8 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Apr 27 12:54:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* numeric.c (int_pow): rb_big_pow() may return other than Bignum.
|
||||
|
||||
Fri Apr 27 01:51:50 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* compile.c: support multiple splat (e.g, [a, *b, *c, e, *f]).
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue