Blowfish in Python?
Michael Zawrotny
zawrotny at gecko.sb.fsu.edu
Tue Feb 29 12:11:49 EST 2000
Markus,
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.
Mike
--
Michael Zawrotny
411 Molecular Biophysics Building
Florida State University | email: zawrotny at sb.fsu.edu
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
More information about the Python-list
mailing list