HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

Python Bitwise Operators


Bitwise operators are used to compare (binary) numbers.


Types of Bitwise Operators


Name Description Example
AND Sets each bit to 1 if both bits are 1 a & b
OR Sets each bit to 1 if one of two bits is 1 a | b
XOR Sets each bit to 1 if only one of two bits is 1 a ^ b
NOT Inverts all the bits ~a
Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off a<<3
Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off a>>3