[issue1205239] Let shift operators take any integer value

Craig McQueen report at bugs.python.org
Tue Jan 26 02:06:42 CET 2010


Craig McQueen <python at craig.mcqueen.id.au> added the comment:

Just for the record... here is a relevant use case...

I'm working on some code for calculating CRCs, and hope to support any CRC width, including CRC-5. This involves, among the calculations:

    crc >> (crc_width - 8)

The complete expression is:

    crc = table[((crc >> (crc_width - 8)) ^ data_byte) & 0xFF] ^ (crc << 8)

where crc_width is typically 32 or 16, but in the case of CRC-5 would be 5.

I think the calculation would work fine for all cases, if only Python allowed me to right-shift with a negative number. But now I'll have to handle the two cases separately.

----------
nosy: +cmcqueen1975

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1205239>
_______________________________________


More information about the Python-bugs-list mailing list