Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1660a61

Browse files
bdbarabanJulienPalard
authored andcommitted
bpo-23460: Fix documentation for decimal string :g formatting (GH-11850)
1 parent 1a53c78 commit 1660a61

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Doc/library/string.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,10 @@ The available presentation types for floating point and decimal values are:
500500
| | |
501501
| | The precise rules are as follows: suppose that the |
502502
| | 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 |
506507
| | ``p-1-exp``. Otherwise, the number is formatted |
507508
| | with presentation type ``'e'`` and precision ``p-1``. |
508509
| | In both cases insignificant trailing zeros are removed |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)