[issue1205239] Let shift operators take any integer value

2011-08-07 Thread Craig McQueen
Craig McQueen added the comment: So this has been rejected I see. Too bad, since I stub my metaphorical toe on this issue from time to time. Just for the record, here is an example: http://stackoverflow.com/questions/4130936/perfect-hash-function/6976723#6976723 -- __

[issue1205239] Let shift operators take any integer value

2010-01-26 Thread Craig McQueen
Craig McQueen 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: c

[issue1205239] Let shift operators take any integer value

2010-01-26 Thread Craig McQueen
Craig McQueen added the comment: Thanks, good points. I'm thinking with a C background and the fixed-width data types. The 0xFF could be needed if the data_byte is actually a larger number and you need to ensure only the lowest 8 bits are set. Or, if there is some sign-extending going on with

[issue1205239] Let shift operators take any integer value

2010-01-26 Thread Mark Dickinson
Mark Dickinson added the comment: One other thought: you could always compute the expression crc >> (crc_width - 8) as crc << 8 >> crc_width Since you're computing crc << 8 anyway, this doesn't increase the operations count, so probably wouldn't significant impact performance.

[issue1205239] Let shift operators take any integer value

2010-01-26 Thread Mark Dickinson
Mark Dickinson added the comment: Interesting. I agree that that looks like a case where it would be desirable for a >> -n to do a << n. By the way, I don't think your formula is quite correct: your crc is going to grow unboundedly as extra data bytes come in. I suspect that you want to ma

[issue1205239] Let shift operators take any integer value

2010-01-25 Thread Craig McQueen
Craig McQueen 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 = t

[issue1205239] Let shift operators take any integer value

2009-04-24 Thread Mark Dickinson
Mark Dickinson added the comment: Rejecting this due to: - no activity for almost 4 years - lack of positive responses Also, I'm -1 on this change: for me, a "x << n" that silently becomes "x >> -n" when n is negative would cause more harm than good. In most of my uses, left and right sh

[issue1205239] Let shift operators take any integer value

2009-01-30 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +marketdickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://