8000 Numbers · gto76/python-cheatsheet@fea82d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fea82d5

Browse files
committed
Numbers
1 parent 79fca70 commit fea82d5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Numbers
500500
<Decimal> = decimal.Decimal(<str/int/tuple>) # E.g. `Decimal((1, (2, 3), 4)) == -230_000`.
501501
```
502502
* **`'int(<str>)'` and `'float(<str>)'` raise ValueError on malformed strings.**
503-
* **Decimal numbers are stored exactly, unlike most floats where `'1.1 + 2.2 != 3.3'`.**
503+
* **Decimal objects store numbers exactly, unlike most floats where `'1.1 + 2.2 != 3.3'`.**
504504
* **Floats can be compared with: `'math.isclose(<float>, <float>)'`.**
505505
* **Precision of decimal operations is set with: `'decimal.getcontext().prec = <int>'`.**
506506
* **Bools can be used anywhere ints can, because bool is a subclass of int: `'True + 1 == 2'`.**

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@
462462

463463
<ul>
464464
<li><strong><code class="python hljs"><span class="hljs-string">'int(&lt;str&gt;)'</span></code> and <code class="python hljs"><span class="hljs-string">'float(&lt;str&gt;)'</span></code> raise ValueError on malformed strings.</strong></li>
465-
<li><strong>Decimal numbers are stored exactly, unlike most floats where <code class="python hljs"><span class="hljs-string">'1.1 + 2.2 != 3.3'</span></code>.</strong></li>
465+
<li><strong>Decimal objects store numbers exactly, unlike most floats where <code class="python hljs"><span class="hljs-string">'1.1 + 2.2 != 3.3'</span></code>.</strong></li>
466466
<li><strong>Floats can be compared with: <code class="python hljs"><span class="hljs-string">'math.isclose(&lt;float&gt;, &lt;float&gt;)'</span></code>.</strong></li>
467467
<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>
468468
<li><strong>Bools can be used anywhere ints can, because bool is a subclass of int: <code class="python hljs"><span class="hljs-string">'True + 1 == 2'</span></code>.</strong></li>

0 commit comments

Comments
 (0)
0