shift operators?

Joshua Muskovitz joshm at taconic.net
Mon Jan 7 17:09:30 EST 2002


<rant>
Is there a way to to right shift (>>) in a non-sign-extended way, short of
my evil hack:

def rshift(num, dist):
    if dist == 0:
        return num
    else:
        return ( (num >> dist) & (0x7fffffff >> (dist-1) ) )

I found it very annoying that there was no simple unsigned right shift in
Python.  And it made debugging my DES port a nightmare, until I figured out
what was going on.
</rant>

-- j




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list