python bitwise operators order code example
Example 1: python bitwise operators methods
OPERATOR DESCRIPTION SYNTAX FUNCTION IN-PLACE METHOD
& Bitwise AND a & b and_(a, b) __and__(self, other)
| Bitwise OR a | b or_(a, b) __or__(self, other)
^ Bitwise XOR a ^ b xor(a, b) __xor__(self, other)
~ Bitwise NOT ~ a invert(a) __invert__(self)
<< Bitwise L shift a << b lshift(a, b) __lshift__(self, other)
>> Bitwise R shift a >> b rshift(a, b) __irshift__(self, other)
Example 2: bitwise operators python
OPERATOR DESCRIPTION SYNTAX
& Bitwise AND x & y
| Bitwise OR x | y
~ Bitwise NOT ~x
^ Bitwise XOR x ^ y
>> Bitwise right shift x>>
<< Bitwise left shift x<<