From f5e11045eebff51984d81f52f90b8271e1c31448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 25 Jul 2019 15:42:34 +0200 Subject: [PATCH] Numbers --- README.md | 8 ++------ index.html | 10 +++------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 516098f..1134a85 100644 --- a/README.md +++ b/README.md @@ -474,19 +474,15 @@ Format Numbers ------- -### Built-in Types +### Types ```python = int() # Or: math.floor() = float() = complex(real=0, imag=0) # Or: + j -``` -* **`'int()'` and `'float()'` raise ValueError on malformed strings.** - -### Importable Types -```python = fractions.Fraction(numerator=0, denominator=1) = decimal.Decimal() ``` +* **`'int()'` and `'float()'` raise ValueError on malformed strings.** * **Decimal numbers can be represented exactly, unlike floats where `'1.1 + 2.2 != 3.3'`.** * **Their precision can be adjusted with `'decimal.getcontext().prec = '`.** diff --git a/index.html b/index.html index fd0517d..9c50999 100644 --- a/index.html +++ b/index.html @@ -553,20 +553,16 @@ to_exclusive = <range>.stop {90:b} # '1011010' -

#Numbers

Built-in Types

<int>      = int(<float/str/bool>)    # Or: math.floor(<float>)
+

#Numbers

Types

<int>      = int(<float/str/bool>)    # Or: math.floor(<float>)
 <float>    = float(<int/str/bool>)
 <complex>  = complex(real=0, imag=0)  # Or: <real> + <real>j
+<Fraction> = fractions.Fraction(numerator=0, denominator=1)
+<Decimal>  = decimal.Decimal(<int/float/str>)
 
  • 'int(<str>)' and 'float(<str>)' raise ValueError on malformed strings.
  • -
-

Importable Types

<Fraction> = fractions.Fraction(numerator=0, denominator=1)
-<Decimal>  = decimal.Decimal(<int/float/str>)
-
- -
  • Decimal numbers can be represented exactly, unlike floats where '1.1 + 2.2 != 3.3'.
  • Their precision can be adjusted with 'decimal.getcontext().prec = <int>'.