On Mar 26, 5:42 pm, Sal <[EMAIL PROTECTED]> wrote:
> Is there any way to do an unsigned shift right in Python? When I enter
> (-1>>1) the answer is -1. What I'm looking for is the equivalent of an
> unsigned shift in C or the ">>>" operator in Java.

What answer were you hoping for, and why?  2**31-1? 2**63-1?

If you're thinking of the -1 as representing a particular
fixed-width bit pattern, try doing a bitwise 'and' operation
with a suitable mask first.  For example, if you're thinking
of -1 as a 32-bit quantity, then

(-1 & (2**32-1)) >> 1

might produce what you want.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to