Craig McQueen <pyt...@craig.mcqueen.id.au> added the comment:

To complete that thought...

Since crc << 8 could bump the calculation into long territory, for that final 
mask I guess I'd want to mask and then shift. I.e. rather than

    crc_mask = ((1 << crc_width) - 1)
    crc = (...) ^ ((crc << 8) & crc_mask)

do:

    crc_lower_mask = ((1 << (crc_width - 8)) - 1)
    crc = (...) ^ ((crc & crc_lower_mask) << 8)

But that expression should evaluate to 0 if crc_width <= 8, so I guess I'll 
need to special-case it. And if I special-case it, I don't need to shift by a 
negative value after all!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1205239>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to