summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-05 07:45:02 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-05 07:45:02 +0000
commit42b4e02760c725e1a426b6845695ecdbc8fe3e3b (patch)
treef6e11bc65b797bc736b83f58841357ccefcdb6bc /numeric.c
parent890d25d46f30b5557c2cc1d66333fa48bdf76918 (diff)
* numeric.c (int_pow): fix previous nubu's commit.
* test/ruby/test_fixnum.rb: new test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index 7402f1527c..f0b827aacc 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2188,7 +2188,10 @@ int_pow(x, y)
long z = 1;
if (neg) x = -x;
- if (y & 1) z = x;
+ if (y & 1)
+ z = x;
+ else
+ neg = 0;
y &= ~1;
do {
while (y % 2 == 0) {
@@ -2209,7 +2212,7 @@ int_pow(x, y)
z = xz;
}
} while (--y);
- if (neg && (y & 1)) z = -z;
+ if (neg) z = -z;
return LONG2NUM(z);
}