Bitwise operators. Differences from javascript and PHP.

John Machin sjmachin at lexicon.net
Fri Nov 17 05:53:01 EST 2006



On Nov 17, 9:38 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> John Machin wrote:
> >http://theopensourcery.com/phplogic.htm
>
> > "In effect the bitwise operations [words "can be" omitted, I presume]"can only be", more likely.

Yes, probably.

>
> > 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

from struct, more likely?

>  >>> o = unpack("i", pack("d", v)[:4])[0]
>  >>> (-o>>(13-3))|-2<<(32-13-1)
> -212992
>
> territory.
>

Sounds like you could be correct. However it's possible that you have
aided and abetted the OP to perpetrate a nonsense :-)

Cheers,
John




More information about the Python-list mailing list