@@ -514,6 +514,8 @@ The available presentation types for :class:`float` and
514
514
| | this rounds the number to ``p `` significant digits and |
515
515
| | then formats the result in either fixed-point format |
516
516
| | or in scientific notation, depending on its magnitude. |
517
+ | | A precision of ``0 `` is treated as equivalent to a |
518
+ | | precision of ``1 ``. |
517
519
| | |
518
520
| | The precise rules are as follows: suppose that the |
519
521
| | result formatted with presentation type ``'e' `` and |
@@ -528,16 +530,19 @@ The available presentation types for :class:`float` and
528
530
| | removed if there are no remaining digits following it, |
529
531
| | unless the ``'#' `` option is used. |
530
532
| | |
533
+ | | With no precision given, uses a precision of ``6 `` |
534
+ | | significant digits for :class: `float `. For |
535
+ | | :class: `~decimal.Decimal `, the coefficient of the result |
536
+ | | is formed from the coefficient digits of the value; |
537
+ | | scientific notation is used for values smaller than |
538
+ | | ``1e-6 `` in absolute value and values where the place |
539
+ | | value of the least significant digit is larger than 1, |
540
+ | | and fixed-point notation is used otherwise. |
541
+ | | |
531
542
| | Positive and negative infinity, positive and negative |
532
543
| | zero, and nans, are formatted as ``inf ``, ``-inf ``, |
533
544
| | ``0 ``, ``-0 `` and ``nan `` respectively, regardless of |
534
545
| | the precision. |
535
- | | |
536
- | | A precision of ``0 `` is treated as equivalent to a |
537
- | | precision of ``1 ``. With no precision given, uses a |
538
- | | precision of ``6 `` significant digits for |
539
- | | :class: `float `, and shows all coefficient digits |
540
- | | for :class: `~decimal.Decimal `. |
541
546
+---------+----------------------------------------------------------+
542
547
| ``'G' `` | General format. Same as ``'g' `` except switches to |
543
548
| | ``'E' `` if the number gets too large. The |
@@ -550,12 +555,18 @@ The available presentation types for :class:`float` and
550
555
| ``'%' `` | Percentage. Multiplies the number by 100 and displays |
551
556
| | in fixed (``'f' ``) format, followed by a percent sign. |
552
557
+---------+----------------------------------------------------------+
553
- | None | Similar to ``'g' ``, except that fixed-point notation, |
554
- | | when used, has at least one digit past the decimal point.|
555
- | | The default precision is as high as needed to represent |
556
- | | the particular value. The overall effect is to match the |
557
- | | output of :func: `str ` as altered by the other format |
558
- | | modifiers. |
558
+ | None | For :class: `float ` this is the same as ``'g' ``, except |
559
+ | | that when fixed-point notation is used to format the |
560
+ | | result, it always includes at least one digit past the |
561
+ | | decimal point. The precision used is as large as needed |
562
+ | | to represent the given value faithfully. |
563
+ | | |
564
+ | | For :class: `~decimal.Decimal `, this is the same as |
565
+ | | either ``'g' `` or ``'G' `` depending on the value of |
566
+ | | ``context.capitals `` for the current decimal context. |
567
+ | | |
568
+ | | The overall effect is to match the output of :func: `str ` |
569
+ | | as altered by the other format modifiers. |
559
570
+---------+----------------------------------------------------------+
560
571
561
572
0 commit comments