Blowfish in Python?

Michael Zawrotny zawrotny at
Tue Feb 29 18:11:49 CET 2000


On 29 Feb 2000, Markus Stenberg <mstenber at cc.Helsinki.FI> wrote:
> Hmm.. As far as I'm concerned, shifts for example do screw up.
> i.e.
> 0xffffffff >> 30
> [64bit Python: 3]
> [32bit Python: -1]
> As far as I'm concerned, that should _not_ happen. Or maybe it's just me.

In an ideal world, perhaps not.  It does seem to be one of those places
that the standard allows implementors some leeway in behavior.  K&R 2nd 
Ed. p. 49 says:

Right shifting an unsigned quantity always fills vacated bits with zero.
Right shifting a signed quantity will fill with sign bits ("arithmetic
shift") on some machines and with 0-bits ("logical shift") on others.

Admittedly K&R isn't the official standard, but the 2nd edition claims
to cover ANSI standard behavior.


Michael Zawrotny
411 Molecular Biophysics Building
Florida State University		| email:  zawrotny at
Tallahassee, FL 32306-4380		| phone:  (850) 644-0069

More information about the Python-list mailing list