Bitwise operators. Differences from javascript and PHP.

Fredrik Lundh fredrik at pythonware.com
Fri Nov 17 05:38:14 EST 2006


John Machin wrote:

> http://theopensourcery.com/phplogic.htm
> 
> "In effect the bitwise operations [words "can be" omitted, I presume]

"can only be", more likely.

> safely applied to integer variables - their effect on booleans,
> float/double or string variables can be predicted but are not really
> useful" ???

sounds like we're in

 >>> v = float(4653896912)
 >>> from string import pack, unpack
 >>> o = unpack("i", pack("d", v)[:4])[0]
 >>> (-o>>(13-3))|-2<<(32-13-1)
-212992

territory.

</F>




More information about the Python-list mailing list