Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(112366)

Side by Side Diff: Doc/library/decimal.rst

Issue 23460: Decimals do not obey ':g' exponential notation formatting rules
Patch Set: Created 4 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Doc/library/string.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`decimal` --- Decimal fixed point and floating point arithmetic 1 :mod:`decimal` --- Decimal fixed point and floating point arithmetic
2 ==================================================================== 2 ====================================================================
3 3
4 .. module:: decimal 4 .. module:: decimal
5 :synopsis: Implementation of the General Decimal Arithmetic Specification. 5 :synopsis: Implementation of the General Decimal Arithmetic Specification.
6 6
7 .. moduleauthor:: Eric Price <eprice at tjhsst.edu> 7 .. moduleauthor:: Eric Price <eprice at tjhsst.edu>
8 .. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar> 8 .. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar>
9 .. moduleauthor:: Raymond Hettinger <python at rcn.com> 9 .. moduleauthor:: Raymond Hettinger <python at rcn.com>
10 .. moduleauthor:: Aahz <aahz at pobox.com> 10 .. moduleauthor:: Aahz <aahz at pobox.com>
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 :const:`Rounded` as appropriate if rounding occurs. The rounding mode is 854 :const:`Rounded` as appropriate if rounding occurs. The rounding mode is
855 determined by the ``rounding`` parameter if given, else by the given 855 determined by the ``rounding`` parameter if given, else by the given
856 ``context``. If neither parameter is given then the rounding mode of the 856 ``context``. If neither parameter is given then the rounding mode of the
857 current context is used. 857 current context is used.
858 858
859 .. method:: to_integral_value(rounding=None, context=None) 859 .. method:: to_integral_value(rounding=None, context=None)
860 860
861 Round to the nearest integer without signaling :const:`Inexact` or 861 Round to the nearest integer without signaling :const:`Inexact` or
862 :const:`Rounded`. If given, applies *rounding*; otherwise, uses the 862 :const:`Rounded`. If given, applies *rounding*; otherwise, uses the
863 rounding method in either the supplied *context* or the current context. 863 rounding method in either the supplied *context* or the current context.
864
865 .. method:: __format__(format)
866
867 Format as string using the given ``format``.
868
869 This makes it possible to specify format string for a :class:`Decimal`
870 object when using :meth:`str.format`. For a complete list of formatting
871 directives, see :ref:`formatspec`.
864 872
865 873
866 .. _logical_operands_label: 874 .. _logical_operands_label:
867 875
868 Logical operands 876 Logical operands
869 ^^^^^^^^^^^^^^^^ 877 ^^^^^^^^^^^^^^^^
870 878
871 The :meth:`logical_and`, :meth:`logical_invert`, :meth:`logical_or`, 879 The :meth:`logical_and`, :meth:`logical_invert`, :meth:`logical_or`,
872 and :meth:`logical_xor` methods expect their arguments to be *logical 880 and :meth:`logical_xor` methods expect their arguments to be *logical
873 operands*. A *logical operand* is a :class:`Decimal` instance whose 881 operands*. A *logical operand* is a :class:`Decimal` instance whose
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2089
2082 >>> getcontext().prec = 3 2090 >>> getcontext().prec = 3
2083 >>> +Decimal('1.23456789') # unary plus triggers rounding 2091 >>> +Decimal('1.23456789') # unary plus triggers rounding
2084 Decimal('1.23') 2092 Decimal('1.23')
2085 2093
2086 Alternatively, inputs can be rounded upon creation using the 2094 Alternatively, inputs can be rounded upon creation using the
2087 :meth:`Context.create_decimal` method: 2095 :meth:`Context.create_decimal` method:
2088 2096
2089 >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678') 2097 >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678')
2090 Decimal('1.2345') 2098 Decimal('1.2345')
OLDNEW
« no previous file with comments | « no previous file | Doc/library/string.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+