From 154013a3e1910bffa189b3e523bbe2a519b9ca35 Mon Sep 17 00:00:00 2001 From: 1nftf Date: Sat, 29 Nov 2025 21:44:45 +0800 Subject: [PATCH 1/2] Add description about the exponent of result formatted with presentation type 'e'. --- Doc/library/string.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 58c836c7382330..1d863751508c90 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -546,6 +546,11 @@ The available presentation types for :class:`float` and | | :class:`float`, and shows all coefficient digits | | | for :class:`~decimal.Decimal`. If ``p=0``, the decimal | | | point is omitted unless the ``#`` option is used. | + | | | + | | The number of zeros padding to the exponent is | + | | determined by the implementation. When the coefficient | + | | is zero, the exponent value is also determined by the | + | | implementation. | +---------+----------------------------------------------------------+ | ``'E'`` | Scientific notation. Same as ``'e'`` except it uses | | | an upper case 'E' as the separator character. | From 52adc1af1abfb4f71fd476833a9b86b2e16d0634 Mon Sep 17 00:00:00 2001 From: 1nftf Date: Fri, 5 Dec 2025 21:26:08 +0800 Subject: [PATCH 2/2] Add details about formatting float with the e/E symbol by __format__. --- Doc/library/string.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 1d863751508c90..e3ad018d1d073b 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -547,10 +547,8 @@ The available presentation types for :class:`float` and | | for :class:`~decimal.Decimal`. If ``p=0``, the decimal | | | point is omitted unless the ``#`` option is used. | | | | - | | The number of zeros padding to the exponent is | - | | determined by the implementation. When the coefficient | - | | is zero, the exponent value is also determined by the | - | | implementation. | + | | For :class:`float`, the exponent always contains at | + | | least two digits, and is zero if the value is zero. | +---------+----------------------------------------------------------+ | ``'E'`` | Scientific notation. Same as ``'e'`` except it uses | | | an upper case 'E' as the separator character. |