wilkice / writing

Something during learning to code.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Bitwise in Python #2

Open wilkice opened 5 years ago

wilkice commented 5 years ago

Bitwise

change Python Integer to 0b

Bitwise OR |

1 | 0 = 0 | 1 = 1 | 1 = 1
0 | 0 = 0
1010 | 0100 = 0000

Bitwise XOR ^

1 ^ 0 = 1
0 ^ 0 = 0
1 ^ 1 = 0
0 ^ 1 = 1
1010 ^ 0100 = 1110

Bitwise AND &

1 & 0 = 0 & 1 = 0 & 0 = 0
1 & 1 = 1

Usage: Single Number

Reference: