bpo-23460: Fix documentation for decimal string :g formatting (GH-11850) · python/cpython@1660a61 (original) (raw)

File tree

2 files changed

lines changed

2 files changed

lines changed

| Original file line number | Diff line number | Diff line change | | | | ------------------------------------------------------------------------------------------------ | ---------------- | ---------------------------------------------------------------- | ------------------------------------------------------------- | | | @@ -500,9 +500,10 @@ The available presentation types for floating point and decimal values are: | | | | | | 500 | 500 | | | | | | 501 | 501 | | | The precise rules are as follows: suppose that the | | | 502 | 502 | | | result formatted with presentation type ``'e'`` and | | | 503 | | - | | precision ``p-1`` would have exponent ``exp``. Then | | | 504 | | - | | if ``-4 <= exp < p``, the number is formatted | | | 505 | | - | | with presentation type ``'f'`` and precision | | | | 503 | + | | precision ``p-1`` would have exponent ``exp``. Then, | | | | | 504 | + | | if ``m <= exp < p``, where ``m`` is -4 for floats and -6 | | | | | 505 | + | | for :class:`Decimals <decimal.Decimal>`, the number is | | | | | 506 | + | | formatted with presentation type ``'f'`` and precision | | | | 506 | 507 | | | ``p-1-exp``. Otherwise, the number is formatted | | | 507 | 508 | | | with presentation type ``'e'`` and precision ``p-1``. | | | 508 | 509 | | | In both cases insignificant trailing zeros are removed | |

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 +The documentation for decimal string formatting using the `:g` specifier has been updated to reflect the correct exponential notation cutoff point. Original patch contributed by Tuomas Suutari.