sign extend now generates the same output for 2.2.2 and 2.4.1 (python versions)

This commit is contained in:
Dave Schuyler 2005-04-30 02:59:32 +00:00
parent 866645f18c
commit 8580dddb60

View File

@ -311,14 +311,9 @@ class ClockDelta(DirectObject.DirectObject):
Preserves the lower NetworkTimeBits of the networkTime value, Preserves the lower NetworkTimeBits of the networkTime value,
and extends the sign bit all the way up. and extends the sign bit all the way up.
""" """
if 1: # this may not be exacly what is wanted (it wraps the value), but
r = ((networkTime & NetworkTimeMask) << NetworkTimeTopBits) >> NetworkTimeTopBits # it matches the output that the old code did with Python 2.2.2.
else: r = ((networkTime+32768) & NetworkTimeMask) - 32768
if networkTime < 0:
# flip the sign, mask it as if it were positive, flip the sign back:
r = (networkTime * -1 & NetworkTimeSignedMask) * -1
else:
r = networkTime & NetworkTimeSignedMask
assert -32768 <= r <= 32767 assert -32768 <= r <= 32767
return r return r