unsigned ints and operator.rshift

Joe Connellan joec at mill.co.uk
Mon Jul 22 11:42:32 EDT 2002


bingo! thanks

Michael Hudson wrote:

> Joe Connellan <joec at mill.co.uk> writes:
>
> > I'm storing info in an int (32bits) that I'm wanting to shift left and
> > right using operator.[l|r]shift the problem is that because the int is
> > signed rshift fills in 1's rather than 0's on negative numbers - is
> > there any way to store the 32bits as an unsigned int do get around this?
>
> Use longs and keep masking?  There's no guarantee that Python int's
> are 32 bits -- they're 64 bits on alphas f'ex.
>
> Cheers,
> M.
>
> --
>   LINTILLA:  You could take some evening classes.
>     ARTHUR:  What, here?
>   LINTILLA:  Yes, I've got a bottle of them.  Little pink ones.
>                    -- The Hitch-Hikers Guide to the Galaxy, Episode 12




More information about the Python-list mailing list