[issue7051] 'g'/'G' format docs need a little more explanation
Mark Dickinson
report at bugs.python.org
Thu Oct 8 20:24:37 CEST 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
Thanks, Eric. I noticed that the description was missing details of
what happens to trailing zeros (i.e., they're removed) and what happens
to special values: infinities, zeros, nans. Here's the revised revised
text:
General format. For a given precision ``p >= 1``, this rounds the
number to ``p`` significant digits and then formats the result in
either fixed-point format or in scientific notation, depending on its
magnitude. The precise rules are as follows: suppose that the result
formatted with presentation type ``e`` and precision ``p-1`` would
have exponent ``exp``. Then if ``-4 <= exp < p``, the number is
formatted as if with presentation type ``f`` and precision
``p-1-exp``. Otherwise, the number is formatted as if with
presentation type ``e`` and precision ``p-1``. In both cases trailing
zeros are removed from the significand, as is the decimal point if
there are no remaining digits following it.
Postive and negative infinity, positive and negative zero, and nans,
are formatted as ``inf``, ``-inf``, ``0``, ``-0`` and ``nan``
respectively.
A precision of ``0`` is treated as equivalent to a precision of ``1``.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7051>
_______________________________________
More information about the Python-bugs-list
mailing list