Table of Contents
show
- Bitwise operators are used to compare (binary) numbers
- Consider x = 2, y = 3
Example
x=2
y=3
print("x&y",x&y)
print("x|y",x|y)
print("x^y",x^y)
print("~x",~x)
print("x<<y",x<<y)
print("x>>y",x>>y)
Output
('x&y', 2)
('x|y', 3)
('x^y', 1)
('~x', -3)
('x<<y', 16)
('x>>y', 0)
Views: 4