From 67f420db721bcce6b04f0b9010624da10770266f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 6 May 2019 03:58:06 +0200 Subject: [PATCH] Bitwise operators --- README.md | 12 +++++++++++- index.html | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8790adc..54d7569 100644 --- a/README.md +++ b/README.md @@ -445,7 +445,17 @@ shuffle() = 0b # Or: 0x = int('0b', 0) # Or: int('0x', 0) = int('', 2) # Or: int('', 16) -'0b' = bin() # Or: '0x' = hex() +'0b' = bin() # Or: '0x' = hex() +``` + +### Bitwise Operators +```python + = & # And + = | # Or + = ^ # Xor (0 if both bits equal) + = << n_bits # Shift left + = >> n_bits # Shift right + = ~ # Compliment (flips bits) ``` diff --git a/index.html b/index.html index e095399..59d5298 100644 --- a/index.html +++ b/index.html @@ -504,7 +504,15 @@ shuffle(<list>)
<int>     = 0b<bin>            # Or: 0x<hex>
 <int>     = int('0b<bin>', 0)  # Or: int('0x<hex>', 0)
 <int>     = int('<bin>', 2)    # Or: int('<hex>', 16)
-'0b<bin>' = bin(<int>)         # Or: '0x<bin>' = hex(<int>)
+'0b<bin>' = bin(<int>)         # Or: '0x<hex>' = hex(<int>)
+
+

Bitwise Operators

+
<int>     = <int> & <int>      # And
+<int>     = <int> | <int>      # Or
+<int>     = <int> ^ <int>      # Xor (0 if both bits equal)
+<int>     = <int> << n_bits    # Shift left
+<int>     = <int> >> n_bits    # Shift right
+<int>     = ~<int>             # Compliment (flips bits)
 

#Combinatorics