Browse Source

Numbers

pull/46/head
Jure Šorn 5 years ago
parent
commit
e895ede840
2 changed files with 6 additions and 8 deletions
  1. 7
      README.md
  2. 7
      index.html

7
README.md

@ -483,7 +483,7 @@ Numbers
### Types
```python
<int> = int(<float/str/bool>) # Or: math.floor(<float>)
<float> = float(<int/str/bool>)
<float> = float(<int/str/bool>) # Or: <real>±e<int>
<complex> = complex(real=0, imag=0) # Or: <real> + <real>j
<Fraction> = fractions.Fraction(numerator=0, denominator=1)
<Decimal> = decimal.Decimal(<str/int/float>)
@ -495,9 +495,8 @@ Numbers
### Basic Functions
```python
<num> = pow(<num>, <num>) # Or: <num> ** <num>
<num> = abs(<num>)
<int> = round(<num>)
<num> = round(<num>, ±ndigits) # `round(126, -1) == 130`
<num> = abs(<num>) # <float> = abs(<complex>)
<num> = round(<num> [, ±ndigits]) # `round(126, -1) == 130`
```
### Math

7
index.html

@ -563,7 +563,7 @@ to_exclusive = &lt;range&gt;.stop
</code></pre></div>
<div><h2 id="numbers"><a href="#numbers" name="numbers">#</a>Numbers</h2><div><h3 id="types">Types</h3><pre><code class="python language-python hljs">&lt;int&gt; = int(&lt;float/str/bool&gt;) <span class="hljs-comment"># Or: math.floor(&lt;float&gt;)</span>
&lt;float&gt; = float(&lt;int/str/bool&gt;)
&lt;float&gt; = float(&lt;int/str/bool&gt;) <span class="hljs-comment"># Or: &lt;real&gt;±e&lt;int&gt;</span>
&lt;complex&gt; = complex(real=<span class="hljs-number">0</span>, imag=<span class="hljs-number">0</span>) <span class="hljs-comment"># Or: &lt;real&gt; + &lt;real&gt;j</span>
&lt;Fraction&gt; = fractions.Fraction(numerator=<span class="hljs-number">0</span>, denominator=<span class="hljs-number">1</span>)
&lt;Decimal&gt; = decimal.Decimal(&lt;str/int/float&gt;)
@ -576,9 +576,8 @@ to_exclusive = &lt;range&gt;.stop
<li><strong>Precision of decimal operations is set with: <code class="python hljs"><span class="hljs-string">'decimal.getcontext().prec = &lt;int&gt;'</span></code>.</strong></li>
</ul>
<div><h3 id="basicfunctions">Basic Functions</h3><pre><code class="python language-python hljs">&lt;num&gt; = pow(&lt;num&gt;, &lt;num&gt;) <span class="hljs-comment"># Or: &lt;num&gt; ** &lt;num&gt;</span>
&lt;num&gt; = abs(&lt;num&gt;)
&lt;int&gt; = round(&lt;num&gt;)
&lt;num&gt; = round(&lt;num&gt;, ±ndigits) <span class="hljs-comment"># `round(126, -1) == 130`</span>
&lt;num&gt; = abs(&lt;num&gt;) <span class="hljs-comment"># &lt;float&gt; = abs(&lt;complex&gt;)</span>
&lt;num&gt; = round(&lt;num&gt; [, ±ndigits]) <span class="hljs-comment"># `round(126, -1) == 130`</span>
</code></pre></div>
<div><h3 id="math">Math</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> math <span class="hljs-keyword">import</span> e, pi, inf, nan

Loading…
Cancel
Save