GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — changes to decimal doc · python/cpython@bec8d83

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Doc/library
    • string.rst
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Doc/library/string.rst‎

Copy file name to clipboardExpand all lines: Doc/library/string.rst
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,20 @@ after the decimal point. The rounding mode for :class:`float` matches that
629629
of the :func:`round` builtin. For :class:`~decimal.Decimal`, the rounding
630630
mode of the current :ref:`context <decimal-context>` will be used.
631631

632+
633+
.. note::
634+
635+
The :class:`~decimal.Decimal` type has special formatting behavior:
636+
637+
* When using ``__format__`` (f-strings, ``format()``, ``str.format()``),
638+
Decimal formats with maximum precision only when precision is **omitted**
639+
in ``f``, ``e``, or ``g`` format types. If precision is explicitly specified,
640+
it is respected.
641+
642+
* When using ``%`` formatting (old-style string formatting with the ``%`` operator),
643+
Decimal values are first converted to :class:`float`, which may result in
644+
precision loss.
645+
632646
The available presentation types for :class:`complex` are the same as those for
633647
:class:`float` (``'%'`` is not allowed). Both the real and imaginary components
634648
of a complex number are formatted as floating-point numbers, according to the

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.