[pypy-commit] pypy improve-rbigint: Ensure correct type when doing rshift
stian
noreply at buildbot.pypy.org
Sat Jul 21 18:41:25 CEST 2012
Author: stian
Branch: improve-rbigint
Changeset: r56337:453a2fb08ae3
Date: 2012-06-26 06:28 +0200
http://bitbucket.org/pypy/pypy/changeset/453a2fb08ae3/
Log: Ensure correct type when doing rshift
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -31,10 +31,12 @@
SHIFT = 63
MASK = long((1 << SHIFT) - 1)
UDIGIT_TYPE = r_ulonglong
+ UDIGIT_MASK = longlongmask
else:
SHIFT = 31
MASK = int((1 << SHIFT) - 1)
UDIGIT_TYPE = r_uint
+ UDIGIT_MASK = intmask
FLOAT_MULTIPLIER = float(1 << LONG_BIT) # Because it works.
@@ -486,8 +488,7 @@
if digit == 1:
return self
elif digit and digit & (digit - 1) == 0:
- div = self.rshift(ptwotable[digit])
- return div
+ return self.rshift(ptwotable[digit])
div, mod = _divrem(self, other)
if mod.sign * other.sign == -1:
@@ -727,11 +728,11 @@
wordshift = int_other // SHIFT
newsize = self.numdigits() - wordshift
if newsize <= 0:
- return rbigint()
+ return NULLRBIGINT
loshift = int_other % SHIFT
hishift = SHIFT - loshift
- lomask = intmask((r_uint(1) << hishift) - 1)
+ lomask = UDIGIT_MASK((UDIGIT_TYPE(1) << hishift) - 1)
himask = MASK ^ lomask
z = rbigint([NULLDIGIT] * newsize, self.sign)
i = 0
More information about the pypy-commit
mailing list