Zero-fill shift

Daniel Orner cs993442 at cs.yorku.ca
Wed May 5 14:47:16 EDT 2004


Gary D. Duzan wrote:
> In article <mailman.273.1083771861.25742.python-list at python.org>,
> Daniel Orner  <cs993442 at cs.yorku.ca> wrote:
> 
>>
>>	Great, this works. 8-) Unfortunately, I've run into another problem. In 
>>the Java algorithm, two integers are added. This often results in an 
>>overflow and a negative number, which is the desired result. However, I 
>>can't seem to duplicate that in Python, as adding two integers that are 
>>too large just results in a long (and using the int() method doesn't 
>>work). I've tried various solutions, but haven't come up with something 
>>that duplicates this behavior exactly.
> 
> 
>    You could try scattering "(foo) % 2**32" around wherever there
> could be an overflow.
> 
> 					Gary Duzan
> 					BBN Technologies

	Hmm... no, that'll never get me any negative numbers. I'm trying to 
make sure that the behavior of an overflow actually *happens* rather 
than trying to avoid it.

--Daniel




More information about the Python-list mailing list