Browse Source

Bitwise operators

pull/125/head
Jure Šorn 2 years ago
parent
commit
4c3bfcd01c
2 changed files with 10 additions and 10 deletions
  1. 10
      README.md
  2. 10
      index.html

10
README.md

@ -533,11 +533,11 @@ from random import random, randint, choice, shuffle, gauss, seed
### Bitwise Operators
```python
<int> = <int> & <int> # And: `0b1100 & 0b1010 == 0b1000`.
<int> = <int> | <int> # Or: `0b1100 | 0b1010 == 0b1110`.
<int> = <int> ^ <int> # Xor: `0b1100 ^ 0b1010 == 0b0110`.
<int> = <int> << n_bits # Left shift (>> for right)
<int> = ~<int> # Not (also: -<int> - 1)
<int> = <int> & <int> # And (0b1100 & 0b1010 == 0b1000).
<int> = <int> | <int> # Or (0b1100 | 0b1010 == 0b1110).
<int> = <int> ^ <int> # Xor (0b1100 ^ 0b1010 == 0b0110).
<int> = <int> << n_bits # Left shift (>> for right).
<int> = ~<int> # Not (also: -<int> - 1).
```

10
index.html

@ -482,11 +482,11 @@ to_exclusive = &lt;range&gt;.stop
&lt;str&gt; = bin(&lt;int&gt;) <span class="hljs-comment"># Returns '[-]0b&lt;bin&gt;'.</span>
</code></pre></div>
<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs">&lt;int&gt; = &lt;int&gt; &amp; &lt;int&gt; <span class="hljs-comment"># And: `0b1100 &amp; 0b1010 == 0b1000`.</span>
&lt;int&gt; = &lt;int&gt; | &lt;int&gt; <span class="hljs-comment"># Or: `0b1100 | 0b1010 == 0b1110`.</span>
&lt;int&gt; = &lt;int&gt; ^ &lt;int&gt; <span class="hljs-comment"># Xor: `0b1100 ^ 0b1010 == 0b0110`.</span>
&lt;int&gt; = &lt;int&gt; &lt;&lt; n_bits <span class="hljs-comment"># Left shift (&gt;&gt; for right)</span>
&lt;int&gt; = ~&lt;int&gt; <span class="hljs-comment"># Not (also: -&lt;int&gt; - 1)</span>
<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs">&lt;int&gt; = &lt;int&gt; &amp; &lt;int&gt; <span class="hljs-comment"># And (0b1100 &amp; 0b1010 == 0b1000).</span>
&lt;int&gt; = &lt;int&gt; | &lt;int&gt; <span class="hljs-comment"># Or (0b1100 | 0b1010 == 0b1110).</span>
&lt;int&gt; = &lt;int&gt; ^ &lt;int&gt; <span class="hljs-comment"># Xor (0b1100 ^ 0b1010 == 0b0110).</span>
&lt;int&gt; = &lt;int&gt; &lt;&lt; n_bits <span class="hljs-comment"># Left shift (&gt;&gt; for right).</span>
&lt;int&gt; = ~&lt;int&gt; <span class="hljs-comment"># Not (also: -&lt;int&gt; - 1).</span>
</code></pre></div>
<div><h2 id="combinatorics"><a href="#combinatorics" name="combinatorics">#</a>Combinatorics</h2><ul>

Loading…
Cancel
Save