unsigned ints and operator.rshift
Michael Hudson
mwh at python.net
Mon Jul 22 10:50:40 EDT 2002
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