Bit length of int or long?
Carey Evans
c.evans at clear.net.nz
Sat May 20 00:02:38 EDT 2000
"Darrell Gallion" <darrell at dorb.com> writes:
> Assuming it never hurts to ask.
> >>> x=0xffffffff
> >>> x >> 1
> -1
>
> Wouldn't 0x7fffffff be nice, maybe even a rotate function.
There's been previous threads about this. Unsigned shift right seems
to be quite useful for some cryptographic functions.
I found when rewriting crypt() in Python that nearly all the right
shifts were by constants, so I could write something like
((t >> 18) & 0x3fff)
to trim off the sign bits.
--
Carey Evans http://home.clear.net.nz/pages/c.evans/
"The risk of U.S. national security resting in the hands of adults who play
with children's toys during office hours is left as an exercise to the reader."
- Bruce Martin in RISKS
More information about the Python-list
mailing list